hyper

package module
v0.1.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2020 License: MIT Imports: 13 Imported by: 5

README

Go Report Card GoDoc

hyper-item

Documentation

Index

Constants

View Source
const (
	MethodPOST   = "POST"
	MethodPATCH  = "PATCH"
	MethodDELETE = "DELETE"
)
View Source
const (
	// TypeText is used for parameters of type text/string
	TypeText = "text"
	// TypeHidden is for hidden parameters
	TypeHidden = "hidden"
	// TypeButton is used for parameters of type button
	TypeButton = "button"
	// TypeCheckbox is used for parameters of type checkbox
	TypeCheckbox = "checkbox"
	// TypeColor is used for parameters of type color picker
	TypeColor = "color"
	// TypeDate is used for parameters of type date
	TypeDate = "date"
	// TypeDatetime is used for parameters of type date and time
	TypeDatetime = "datetime"
	// TypeEmail is used for parameters of type e-mail address
	TypeEmail = "email"
	// TypeImage is used for parameters of type image
	TypeImage = "image"
	// TypeMonth is used for parameters of type month
	TypeMonth = "month"
	// TypeNumber is used for parameters of type number
	TypeNumber = "number"
	// TypePassword is used for parameters of type password
	TypePassword = "password"
	// TypeRadio is used for parameters of type radio button
	TypeRadio = "radio"
	// TypeRange is used for parameters of type range
	TypeRange = "range"
	// TypeReset is used for parameters of type reset
	TypeReset = "reset"
	// TypeSearch is used for parameters of type search
	TypeSearch = "search"
	// TypeSubmit is used for parameters of type submit
	TypeSubmit = "submit"
	// TypeTel is used for parameters of type telephone number
	TypeTel = "tel"
	// TypeTime is used for parameters of type time
	TypeTime = "time"
	// TypeURL is used for parameters of type url
	TypeURL = "url"
	// TypeWeek is used for parameters of type week
	TypeWeek = "week"
	// TypeFile is used for parameters of type file
	TypeFile = "file"
)
View Source
const (
	TypeSelect   = "select"
	TypeDatalist = "datalist"
	TypeInteger  = "integer"
	TypeBool     = "bool"
)
View Source
const (
	// RenderNone is used on links or items that should not be displayed in the UI
	RenderNone = "none"
	// RenderTransclude is used on links or items to signal that these should be embedded within the current view.
	RenderTransclude = "transclude"
)
View Source
const (
	HeaderContentType     = "Content-Type" // RFC 7231, 3.1.1.5
	HeaderAccept          = "Accept"
	HeaderAcceptLanguage  = "Accept-Language"
	HeaderAcceptProfile   = "Accept-Profile"
	HeaderIfNoneMatch     = "If-None-Match"
	HeaderIfModifiedSince = "If-Modified-Since"
	HeaderAuthorization   = "Authorization"
	HeaderLocation        = "Location"
)

HTTP headers as registered with IANA. See: https://tools.ietf.org/html/rfc7231

View Source
const (
	ContentTypeHyperItem         = "application/vnd.hyper-item+json"               // https://github.com/mdemuth/hyper-item
	ContentTypeHyperItemUTF8     = "application/vnd.hyper-item+json;charset=UTF-8" // https://github.com/mdemuth/hyper-item
	ContentTypeJSON              = "application/json"                              // https://tools.ietf.org/html/rfc8259
	ContentTypeURLEncoded        = "application/x-www-form-urlencoded"             // http://www.w3.org/TR/html
	ContentTypeMultipartFormData = "multipart/form-data"                           // https://tools.ietf.org/html/rfc2388
)

HTTP content types

View Source
const (
	RelNext     = "next"
	RelPrevious = "previous"
	RelLast     = "last"
	RelFirst    = "first"
	RelSelf     = "self"
	RelDetails  = "details"
	RelSearch   = "search"
)
View Source
const (
	HeaderXForwardedHost   = "X-Forwarded-Host"
	HeaderXForwardedFor    = "X-Forwarded-For"
	HeaderXForwardedProto  = "X-Forwarded-Proto"
	HeaderXForwardedScheme = "X-Forwarded-Scheme"
	HeaderXForwardedPath   = "X-Forwarded-Path"
	HeaderXRealIP          = "X-Real-IP"
	HeaderXCorrelationID   = "X-Correlation-ID"
	HeaderForwarded        = "Forwarded"
)
View Source
const NameAction = "@action"

Variables

This section is empty.

Functions

func Accept

func Accept(typ string) func(*http.Request)

func AcceptLanguage

func AcceptLanguage(spec string) func(*http.Request)

func ActionContextEquals added in v0.1.13

func ActionContextEquals(ctx string) func(Action) bool

func ActionRelEquals

func ActionRelEquals(rel string) func(Action) bool

func ExternalHost

func ExternalHost(r *http.Request) string

func ExternalPath

func ExternalPath(r *http.Request) string

func ExternalScheme

func ExternalScheme(r *http.Request) string

func ExternalURL

func ExternalURL(r *http.Request) *url.URL

func ExtractPropertyName added in v0.1.11

func ExtractPropertyName(p Property) string

func ExtractRemote

func ExtractRemote(r *http.Request) string

func ItemIDEquals

func ItemIDEquals(id string) func(Item) bool

ItemIDEquals is used to Filter a collection of Items by id

func ItemRelEquals

func ItemRelEquals(rel string) func(Item) bool

ItemRelEquals is used to Filter a collection of Items by rel

func LinkRelEquals

func LinkRelEquals(rel string) func(Link) bool

func Named added in v0.1.4

func Named(name string) func(FilterComponent) bool

func Not added in v0.1.4

func Not(accept func(FilterComponent) bool) func(FilterComponent) bool

func ParameterNameEquals added in v0.1.11

func ParameterNameEquals(name string) func(Parameter) bool

func ParameterTypeEquals added in v0.1.11

func ParameterTypeEquals(typ string) func(Parameter) bool

func ParseLimit added in v0.1.4

func ParseLimit(url *url.URL) (uint64, error)

func ParseSkip added in v0.1.4

func ParseSkip(url *url.URL) (uint64, error)

func PropertyNameEquals added in v0.1.12

func PropertyNameEquals(name string) func(Property) bool

func ResolveURL

func ResolveURL(baseURL *url.URL, format string, args ...interface{}) *url.URL

func Write

func Write(w http.ResponseWriter, status int, i Item)

Write writes a hyper-item to the response writer with the given status code.

Types

type Action

type Action struct {
	Label       string     `json:"label,omitempty"`
	Description string     `json:"description,omitempty"`
	Render      []string   `json:"render,omitempty"`
	Rel         string     `json:"rel"`
	Href        string     `json:"href,omitempty"`
	Encoding    string     `json:"encoding,omitempty"`
	Method      string     `json:"method,omitempty"`
	Template    string     `json:"template,omitempty"`
	Parameters  Parameters `json:"parameters,omitempty"`
	Context     string     `json:"context,omitempty"`
	OK          string     `json:"ok,omitempty"`
	Cancel      string     `json:"cancel,omitempty"`
	Reset       string     `json:"reset,omitempty"`
}

Action .

type Actions

type Actions []Action

Actions .

func (Actions) Filter

func (as Actions) Filter(accept func(Action) bool) Actions

Filter .

func (Actions) FilterByContext added in v0.1.13

func (as Actions) FilterByContext(ctx string) Actions

FilterByContext .

func (Actions) Find

func (as Actions) Find(accept func(Action) bool) (Action, bool)

Find .

func (Actions) FindByRel

func (as Actions) FindByRel(rel string) (Action, bool)

FindByRel .

func (Actions) Len

func (as Actions) Len() int

func (Actions) Less

func (as Actions) Less(i, j int) bool

func (Actions) Swap

func (as Actions) Swap(i, j int)

type Arguments

type Arguments map[string]interface{}

func (Arguments) Bool

func (a Arguments) Bool(key string) bool

func (Arguments) Bytes

func (a Arguments) Bytes(key string) []byte

func (Arguments) Float64

func (a Arguments) Float64(key string) float64

func (Arguments) Int

func (a Arguments) Int(key string) int

func (Arguments) Int64

func (a Arguments) Int64(key string) int64

func (Arguments) JSON added in v0.1.6

func (a Arguments) JSON(key string, v interface{}) error

func (Arguments) String

func (a Arguments) String(key string) string

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient() *Client

func (*Client) Fetch

func (c *Client) Fetch(url string, opts ...func(*http.Request)) (Item, error)

func (*Client) FetchRaw

func (c *Client) FetchRaw(url string, opts ...func(*http.Request)) (http.Header, []byte, error)

func (*Client) Submit

func (c *Client) Submit(a Action, args Arguments, opts ...func(*http.Request)) (*http.Response, error)

func (*Client) SubmitDiscard

func (c *Client) SubmitDiscard(a Action, args Arguments, opts ...func(*http.Request)) error

type Command

type Command struct {
	Action    string
	Arguments Arguments
}

func ExtractCommand

func ExtractCommand(r *http.Request) Command

func MakeCommand

func MakeCommand() Command

type ContentType

type ContentType struct {
	Type       string
	Subtype    string
	Parameters map[string]string
}

func ExtractContentType

func ExtractContentType(h http.Header) (ContentType, error)

func (*ContentType) Parse

func (ct *ContentType) Parse(v string) error

func (ContentType) String

func (ct ContentType) String() string

type Error

type Error struct {
	Label       string `json:"label,omitempty"`
	Description string `json:"description,omitempty"`
	Message     string `json:"message"`
	Code        string `json:"code,omitempty"`
}

Error .

type Errors

type Errors []Error

Errors .

func (Errors) Filter added in v0.1.11

func (es Errors) Filter(accept func(e Error) bool) Errors

Filter

func (Errors) Find added in v0.1.11

func (es Errors) Find(accept func(e Error) bool) (Error, bool)

Find

type Filter added in v0.1.4

type Filter []FilterComponent

func ParseFilter added in v0.1.4

func ParseFilter(url *url.URL) (Filter, error)

func (Filter) Filter added in v0.1.4

func (f Filter) Filter(accept func(c FilterComponent) bool) Filter

func (Filter) Find added in v0.1.11

func (f Filter) Find(accept func(FilterComponent) bool) (FilterComponent, bool)

func (Filter) IsZero added in v0.1.4

func (f Filter) IsZero() bool

type FilterComponent added in v0.1.4

type FilterComponent struct {
	Operator FilterOperator `json:"operator,omitempty"`
	Name     string         `json:"name"`
	Value    interface{}    `json:"value,omitempty"`
}

func ParseFilterComponent added in v0.1.4

func ParseFilterComponent(rawFC string) (FilterComponent, error)

func (FilterComponent) ValueBool added in v0.1.4

func (fc FilterComponent) ValueBool() bool

func (FilterComponent) ValueString added in v0.1.4

func (fc FilterComponent) ValueString() string

func (FilterComponent) ValueStrings added in v0.1.4

func (fc FilterComponent) ValueStrings() []string

type FilterComponentConfiguration added in v0.1.4

type FilterComponentConfiguration struct {
	Label       string                        `json:"label,omitempty"`
	Description string                        `json:"description,omitempty"`
	Name        string                        `json:"name"`
	Operators   []FilterOperatorConfiguration `json:"operators,omitempty"`
	Type        string                        `json:"type,omitempty"`
	Options     SelectOptions                 `json:"options,omitempty"`
	Related     string                        `json:"related,omitempty"`
	Placeholder string                        `json:"placeholder,omitempty"`
	Multiple    bool                          `json:"multiple,omitempty"`
}

type FilterConfiguration added in v0.1.4

type FilterConfiguration []FilterComponentConfiguration

func (FilterConfiguration) Len added in v0.1.4

func (c FilterConfiguration) Len() int

func (FilterConfiguration) Less added in v0.1.4

func (c FilterConfiguration) Less(i, j int) bool

func (FilterConfiguration) Swap added in v0.1.4

func (c FilterConfiguration) Swap(i, j int)

type FilterOperator added in v0.1.4

type FilterOperator string
const (
	FilterOperatorEquals              FilterOperator = "eq"
	FilterOperatorNotEquals           FilterOperator = "neq"
	FilterOperatorLessThen            FilterOperator = "lt"
	FilterOperatorGreaterThen         FilterOperator = "gt"
	FilterOperatorLessThenOrEquals    FilterOperator = "leq"
	FilterOperatorGreaterThenOrEquals FilterOperator = "geq"
	FilterOperatorIn                  FilterOperator = "in"
	FilterOperatorNotIn               FilterOperator = "nin"
	FilterOperatorLike                FilterOperator = "like"
	FilterOperatorNotLike             FilterOperator = "nlike"
	FilterOperatorBetween             FilterOperator = "bet"
	FilterOperatorNotBetween          FilterOperator = "nbet"
)

type FilterOperatorConfiguration added in v0.1.4

type FilterOperatorConfiguration struct {
	Label       string         `json:"label,omitempty"`
	Description string         `json:"description,omitempty"`
	Operator    FilterOperator `json:"operator"`
	Infix       string         `json:"infix,omitempty"`
}

func FilterOperatorConfigurationFor added in v0.1.4

func FilterOperatorConfigurationFor(op FilterOperator) FilterOperatorConfiguration

func FilterOperatorConfigurationsForBaseType added in v0.1.4

func FilterOperatorConfigurationsForBaseType(t string) []FilterOperatorConfiguration

func FilterOperatorConfigurationsForDate added in v0.1.4

func FilterOperatorConfigurationsForDate() []FilterOperatorConfiguration

func FilterOperatorConfigurationsForDatetime added in v0.1.4

func FilterOperatorConfigurationsForDatetime() []FilterOperatorConfiguration

func FilterOperatorConfigurationsForDatetimeReduced added in v0.1.4

func FilterOperatorConfigurationsForDatetimeReduced() []FilterOperatorConfiguration

func FilterOperatorConfigurationsForInteger added in v0.1.4

func FilterOperatorConfigurationsForInteger() []FilterOperatorConfiguration

func FilterOperatorConfigurationsForIntegerReduced added in v0.1.4

func FilterOperatorConfigurationsForIntegerReduced() []FilterOperatorConfiguration

func FilterOperatorConfigurationsForNumber added in v0.1.4

func FilterOperatorConfigurationsForNumber() []FilterOperatorConfiguration

func FilterOperatorConfigurationsForNumberReduced added in v0.1.4

func FilterOperatorConfigurationsForNumberReduced() []FilterOperatorConfiguration

func FilterOperatorConfigurationsForSelect added in v0.1.4

func FilterOperatorConfigurationsForSelect() []FilterOperatorConfiguration

func FilterOperatorConfigurationsForText added in v0.1.4

func FilterOperatorConfigurationsForText() []FilterOperatorConfiguration

func FilterOperatorConfigurationsForTextReduced added in v0.1.4

func FilterOperatorConfigurationsForTextReduced() []FilterOperatorConfiguration

type Item

type Item struct {
	Label       string          `json:"label,omitempty"`
	Description string          `json:"description,omitempty"`
	Render      []string        `json:"render,omitempty"`
	Rel         string          `json:"rel,omitempty"`
	ID          string          `json:"id,omitempty"`
	Type        string          `json:"type,omitempty"`
	Properties  Properties      `json:"properties,omitempty"`
	Data        json.RawMessage `json:"data,omitempty"`
	Links       Links           `json:"links,omitempty"`
	Actions     Actions         `json:"actions,omitempty"`
	Items       Items           `json:"items,omitempty"`
	Errors      Errors          `json:"errors,omitempty"`
}

Item has properties, links, actions, (sub-)items and errors.

func ErrorItem added in v0.1.1

func ErrorItem(errs ...error) Item
func Search(root Item, id string) (Item, bool)

Search performs a DFS with the goal to find an item by the specified id

func (*Item) AddAction

func (i *Item) AddAction(a Action)

AddAction adds an Action to this Item

func (*Item) AddActions

func (i *Item) AddActions(as Actions)

AddActions adds many Actions to this Item

func (*Item) AddItem

func (i *Item) AddItem(sub Item)

AddItem adds a (sub-)Item to this Item

func (*Item) AddItems

func (i *Item) AddItems(subs []Item)

AddItems adds many (sub-)Items to this Item

func (i *Item) AddLink(l Link)

AddLink adds a link to this Item

func (i *Item) AddLinks(ls Links)

AddLinks adds many links to this Item

func (*Item) AddProperties

func (i *Item) AddProperties(ps Properties)

AddProperties adds many Properties to this Item

func (*Item) AddProperty

func (i *Item) AddProperty(p Property)

AddProperty add a Property to this Item

func (*Item) DecodeData

func (i *Item) DecodeData(v interface{}) error

func (*Item) EncodeData

func (i *Item) EncodeData(v interface{}) error

type Items

type Items []Item

Items represents a collection of Item

func (Items) Filter

func (is Items) Filter(accept func(Item) bool) Items

Filter returns a collection of Items that conform to the profided specification

func (Items) Find

func (is Items) Find(accept func(Item) bool) (Item, bool)

Find returns an Item that satisfies the specification

func (Items) FindByID

func (is Items) FindByID(id string) (Item, bool)

FindByID returns an Item that has a specific id

func (Items) FindByRel

func (is Items) FindByRel(rel string) (Item, bool)

FindByRel returns an Item that has a specific rel

func (Items) KeyBy

func (is Items) KeyBy(extractKey func(Item) string) map[string]Item

KeyBy calculates a map keyed by the result of the extractKey funktion.

func (Items) KeyByID

func (is Items) KeyByID() map[string]Item

KeyByID returns a map of Items keyed by the Item ids

func (Items) KeyByRel

func (is Items) KeyByRel() map[string]Item

KeyByRel returns a map of Items keyed by the Item rel

type Link struct {
	Label          string     `json:"label,omitempty"`
	Description    string     `json:"description,omitempty"`
	Render         []string   `json:"render,omitempty"`
	Rel            string     `json:"rel"`
	Href           string     `json:"href,omitempty"`
	Type           string     `json:"type,omitempty"`
	Language       string     `json:"language,omitempty"`
	Template       string     `json:"template,omitempty"`
	Parameters     Parameters `json:"parameters,omitempty"`
	Context        string     `json:"context,omitempty"`
	Download       string     `json:"download,omitempty"`
	Accept         string     `json:"accept,omitempty"`
	AcceptLanguage string     `json:"accept-language,omitempty"`
}

Link .

func MakeFilterLink(fc FilterConfiguration, template string, currentFilter Filter, placeholder string) Link
type Links []Link

Links .

func (Links) Filter

func (ls Links) Filter(accept func(Link) bool) Links

Filter .

func (Links) FilterByRel

func (ls Links) FilterByRel(rel string) Links

FilterByRel .

func (Links) Find

func (ls Links) Find(accept func(Link) bool) (Link, bool)

Find .

func (Links) FindByRel

func (ls Links) FindByRel(rel string) (Link, bool)

FindByRel .

type Meta added in v0.1.4

type Meta struct {
	Filter Filter `json:"filter,omitemty"`
	Sort   Sort   `json:"sort,omitempty"`
	Search string `json:"search,omitempty"`
	Skip   uint64 `json:"skip,omitempty"`
	Limit  uint64 `json:"limit,omitempty"`
	After  string `json:"after,omitempty"`
	Before string `json:"before,omitempty"`
}

func ParseMeta added in v0.1.5

func ParseMeta(url *url.URL) (Meta, error)

func (Meta) Clone added in v0.1.4

func (m Meta) Clone() Meta

func (Meta) DefaultSort added in v0.1.4

func (m Meta) DefaultSort(sort Sort) Meta

func (Meta) FilterTemplate added in v0.1.4

func (m Meta) FilterTemplate() string

func (Meta) IsZero added in v0.1.4

func (m Meta) IsZero() bool

func (Meta) MarshalJSON added in v0.1.4

func (m Meta) MarshalJSON() ([]byte, error)

func (Meta) MinLimit added in v0.1.4

func (m Meta) MinLimit(limit uint64) Meta

func (Meta) Next added in v0.1.4

func (m Meta) Next() Meta

func (Meta) Previous added in v0.1.4

func (m Meta) Previous() Meta

func (Meta) Query added in v0.1.4

func (m Meta) Query() string

func (Meta) SearchTemplate added in v0.1.4

func (m Meta) SearchTemplate() string

func (Meta) SortTemplate added in v0.1.4

func (m Meta) SortTemplate() string

func (Meta) WithAfter added in v0.1.4

func (m Meta) WithAfter(id string) Meta

func (Meta) WithBefore added in v0.1.4

func (m Meta) WithBefore(id string) Meta

type Parameter

type Parameter struct {
	Label       string        `json:"label,omitempty"`
	Description string        `json:"description,omitempty"`
	Name        string        `json:"name"`
	Type        string        `json:"type"`
	Accept      string        `json:"accept,omitempty"`
	Value       interface{}   `json:"value,omitempty"`
	Options     SelectOptions `json:"options,omitempty"`
	Related     string        `json:"related,omitempty"`
	Components  interface{}   `json:"components,omitempty"`
	Placeholder string        `json:"placeholder,omitempty"`
	Pattern     string        `json:"pattern,omitempty"`    // pattern to be matched by the value
	Min         interface{}   `json:"min,omitempty"`        // minimum value
	MinLength   interface{}   `json:"min-length,omitempty"` // minimum length of value
	Max         interface{}   `json:"max,omitempty"`        // maximum value
	MaxLength   interface{}   `json:"max-length,omitempty"` // maximum length of value
	Step        interface{}   `json:"step,omitempty"`       // granularity to be matched by the parameter's value
	Rows        interface{}   `json:"rows,omitempty"`       // specifies the visible number of lines in a text area
	Cols        interface{}   `json:"cols,omitempty"`       // specifies the visible width of a text area
	Wrap        interface{}   `json:"wrap,omitempty"`       // specifies how the text in a text area is to be wrapped when submitted in a form
	Required    bool          `json:"required,omitempty"`
	ReadOnly    bool          `json:"read-only,omitempty"`
	Multiple    bool          `json:"multiple,omitempty"`
}

Parameter .

func ActionParameter

func ActionParameter(value string) Parameter

func HiddenParameter added in v0.1.10

func HiddenParameter(name string, value interface{}) Parameter

type Parameters

type Parameters []Parameter

Parameters .

func (Parameters) Filter added in v0.1.11

func (ps Parameters) Filter(accept func(p Parameter) bool) Parameters

Filter

func (Parameters) Find added in v0.1.11

func (ps Parameters) Find(accept func(p Parameter) bool) (Parameter, bool)

Find

func (Parameters) FindByName

func (ps Parameters) FindByName(name string) (Parameter, bool)

FindByName .

type Properties

type Properties []Property

Properties is a collection of Property

func (Properties) Filter added in v0.1.11

func (ps Properties) Filter(accept func(Property) bool) Properties

Filter

func (Properties) Find

func (ps Properties) Find(accept func(p Property) bool) (Property, bool)

Find

func (Properties) FindByName added in v0.1.12

func (ps Properties) FindByName(name string) (Property, bool)

FindByName

func (Properties) KeyBy

func (ps Properties) KeyBy(extractKey func(Property) string) map[string]Property

KeyBy calculates a map keyed by the result of the extractKey funktion.

func (Properties) KeyByName

func (ps Properties) KeyByName() map[string]Property

KeyByName returns a map of Properties keyed by name

type Property

type Property struct {
	Label       string      `json:"label,omitempty"`
	Description string      `json:"description,omitempty"`
	Render      []string    `json:"render,omitempty"`
	Name        string      `json:"name"`
	Value       interface{} `json:"value"`
	Type        string      `json:"type,omitempty"`
	Unit        string      `json:"unit,omitempty"`
	Display     string      `json:"display,omitempty"`
}

Property represents part of a domain state

type Resolver

type Resolver interface {
	Resolve(format string, args ...interface{}) *url.URL
}

type ResolverFunc

type ResolverFunc func(format string, args ...interface{}) *url.URL

func ExternalURLResolver

func ExternalURLResolver(r *http.Request) ResolverFunc

func NewURLResolver

func NewURLResolver(baseURL *url.URL) ResolverFunc

func (ResolverFunc) Resolve

func (fn ResolverFunc) Resolve(format string, args ...interface{}) *url.URL

func (ResolverFunc) ResolverFunc

func (fn ResolverFunc) ResolverFunc(format string, args ...interface{}) ResolverFunc

type SelectOption

type SelectOption struct {
	Label       string        `json:"label,omitempty"`
	Description string        `json:"description,omitempty"`
	Value       interface{}   `json:"value,omitempty"`
	Options     SelectOptions `json:"options,omitempty"`
}

SelectOption .

type SelectOptions

type SelectOptions []SelectOption

SelectOptions .

func (SelectOptions) Len

func (s SelectOptions) Len() int

func (SelectOptions) Less

func (s SelectOptions) Less(i, j int) bool

func (SelectOptions) Swap

func (s SelectOptions) Swap(i, j int)

type Sort added in v0.1.4

type Sort []SortComponent

func ParseSort added in v0.1.4

func ParseSort(url *url.URL) (Sort, error)

func (Sort) FindOne added in v0.1.4

func (s Sort) FindOne(name string) (SortComponent, bool)

func (Sort) IsZero added in v0.1.4

func (s Sort) IsZero() bool

type SortComponent added in v0.1.4

type SortComponent struct {
	Order SortOrder `json:"order"`
	Name  string    `json:"name"`
}

func ParseSortComponent added in v0.1.4

func ParseSortComponent(rawSC string) (SortComponent, error)

type SortComponentConfiguration added in v0.1.4

type SortComponentConfiguration struct {
	Label       string                   `json:"label,omitempty"`
	Description string                   `json:"description,omitempty"`
	Name        string                   `json:"name"`
	Orders      []SortOrderConfiguration `json:"orders,omitempty"`
}

type SortConfiguration added in v0.1.4

type SortConfiguration []SortComponentConfiguration

type SortOrder added in v0.1.4

type SortOrder string
const (
	SortOrderAscending  SortOrder = "ASC"
	SortOrderDescending SortOrder = "DESC"
)

type SortOrderConfiguration added in v0.1.4

type SortOrderConfiguration struct {
	Label       string    `json:"label,omitempty"`
	Description string    `json:"description,omitempty"`
	Order       SortOrder `json:"order"`
}

func MakeSortOperatorConfigurations added in v0.1.4

func MakeSortOperatorConfigurations() []SortOrderConfiguration

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL