Documentation ¶
Index ¶
- Constants
- func Accept(typ string) func(*http.Request)
- func AcceptLanguage(spec string) func(*http.Request)
- func ActionContextEquals(ctx string) func(Action) bool
- func ActionRelEquals(rel string) func(Action) bool
- func ExternalHost(r *http.Request) string
- func ExternalPath(r *http.Request) string
- func ExternalScheme(r *http.Request) string
- func ExternalURL(r *http.Request) *url.URL
- func ExtractPropertyName(p Property) string
- func ExtractRemote(r *http.Request) string
- func ItemIDEquals(id string) func(Item) bool
- func ItemRelEquals(rel string) func(Item) bool
- func LinkRelEquals(rel string) func(Link) bool
- func Named(name string) func(FilterComponent) bool
- func Not(accept func(FilterComponent) bool) func(FilterComponent) bool
- func ParameterNameEquals(name string) func(Parameter) bool
- func ParameterTypeEquals(typ string) func(Parameter) bool
- func ParseLimit(url *url.URL) (uint64, error)
- func ParseSkip(url *url.URL) (uint64, error)
- func PropertyNameEquals(name string) func(Property) bool
- func ResolveURL(baseURL *url.URL, format string, args ...interface{}) *url.URL
- func Write(w http.ResponseWriter, status int, i Item)
- type Action
- type Actions
- func (as Actions) Filter(accept func(Action) bool) Actions
- func (as Actions) FilterByContext(ctx string) Actions
- func (as Actions) Find(accept func(Action) bool) (Action, bool)
- func (as Actions) FindByRel(rel string) (Action, bool)
- func (as Actions) Len() int
- func (as Actions) Less(i, j int) bool
- func (as Actions) Swap(i, j int)
- type Arguments
- func (a Arguments) Bool(key string) bool
- func (a Arguments) Bytes(key string) []byte
- func (a Arguments) Float64(key string) float64
- func (a Arguments) Int(key string) int
- func (a Arguments) Int64(key string) int64
- func (a Arguments) JSON(key string, v interface{}) error
- func (a Arguments) String(key string) string
- type Client
- func (c *Client) Fetch(url string, opts ...func(*http.Request)) (Item, error)
- func (c *Client) FetchRaw(url string, opts ...func(*http.Request)) (http.Header, []byte, error)
- func (c *Client) Submit(a Action, args Arguments, opts ...func(*http.Request)) (*http.Response, error)
- func (c *Client) SubmitDiscard(a Action, args Arguments, opts ...func(*http.Request)) error
- type Command
- type ContentType
- type Error
- type Errors
- type Filter
- type FilterComponent
- type FilterComponentConfiguration
- type FilterConfiguration
- type FilterOperator
- type FilterOperatorConfiguration
- func FilterOperatorConfigurationFor(op FilterOperator) FilterOperatorConfiguration
- func FilterOperatorConfigurationsForBaseType(t string) []FilterOperatorConfiguration
- func FilterOperatorConfigurationsForDate() []FilterOperatorConfiguration
- func FilterOperatorConfigurationsForDatetime() []FilterOperatorConfiguration
- func FilterOperatorConfigurationsForDatetimeReduced() []FilterOperatorConfiguration
- func FilterOperatorConfigurationsForInteger() []FilterOperatorConfiguration
- func FilterOperatorConfigurationsForIntegerReduced() []FilterOperatorConfiguration
- func FilterOperatorConfigurationsForNumber() []FilterOperatorConfiguration
- func FilterOperatorConfigurationsForNumberReduced() []FilterOperatorConfiguration
- func FilterOperatorConfigurationsForSelect() []FilterOperatorConfiguration
- func FilterOperatorConfigurationsForText() []FilterOperatorConfiguration
- func FilterOperatorConfigurationsForTextReduced() []FilterOperatorConfiguration
- type Item
- func (i *Item) AddAction(a Action)
- func (i *Item) AddActions(as Actions)
- func (i *Item) AddItem(sub Item)
- func (i *Item) AddItems(subs []Item)
- func (i *Item) AddLink(l Link)
- func (i *Item) AddLinks(ls Links)
- func (i *Item) AddProperties(ps Properties)
- func (i *Item) AddProperty(p Property)
- func (i *Item) DecodeData(v interface{}) error
- func (i *Item) EncodeData(v interface{}) error
- type Items
- func (is Items) Filter(accept func(Item) bool) Items
- func (is Items) Find(accept func(Item) bool) (Item, bool)
- func (is Items) FindByID(id string) (Item, bool)
- func (is Items) FindByRel(rel string) (Item, bool)
- func (is Items) KeyBy(extractKey func(Item) string) map[string]Item
- func (is Items) KeyByID() map[string]Item
- func (is Items) KeyByRel() map[string]Item
- type Link
- type Links
- type Meta
- func (m Meta) Clone() Meta
- func (m Meta) DefaultSort(sort Sort) Meta
- func (m Meta) FilterTemplate() string
- func (m Meta) IsZero() bool
- func (m Meta) MarshalJSON() ([]byte, error)
- func (m Meta) MinLimit(limit uint64) Meta
- func (m Meta) Next() Meta
- func (m Meta) Previous() Meta
- func (m Meta) Query() string
- func (m Meta) SearchTemplate() string
- func (m Meta) SortTemplate() string
- func (m Meta) WithAfter(id string) Meta
- func (m Meta) WithBefore(id string) Meta
- type Parameter
- type Parameters
- type Properties
- func (ps Properties) Filter(accept func(Property) bool) Properties
- func (ps Properties) Find(accept func(p Property) bool) (Property, bool)
- func (ps Properties) FindByName(name string) (Property, bool)
- func (ps Properties) KeyBy(extractKey func(Property) string) map[string]Property
- func (ps Properties) KeyByName() map[string]Property
- type Property
- type Resolver
- type ResolverFunc
- type SelectOption
- type SelectOptions
- type Sort
- type SortComponent
- type SortComponentConfiguration
- type SortConfiguration
- type SortOrder
- type SortOrderConfiguration
Constants ¶
const ( MethodPOST = "POST" MethodPATCH = "PATCH" MethodDELETE = "DELETE" )
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" )
const ( TypeSelect = "select" TypeDatalist = "datalist" TypeInteger = "integer" TypeBool = "bool" )
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" )
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
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
const ( RelNext = "next" RelPrevious = "previous" RelLast = "last" RelFirst = "first" RelSelf = "self" RelDetails = "details" RelSearch = "search" )
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" )
const NameAction = "@action"
Variables ¶
This section is empty.
Functions ¶
func AcceptLanguage ¶
func ActionContextEquals ¶ added in v0.1.13
func ActionRelEquals ¶
func ExternalHost ¶
func ExternalPath ¶
func ExternalScheme ¶
func ExtractPropertyName ¶ added in v0.1.11
func ExtractRemote ¶
func ItemIDEquals ¶
ItemIDEquals is used to Filter a collection of Items by id
func ItemRelEquals ¶
ItemRelEquals is used to Filter a collection of Items by rel
func LinkRelEquals ¶
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 ParameterTypeEquals ¶ added in v0.1.11
func PropertyNameEquals ¶ added in v0.1.12
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) FilterByContext ¶ added in v0.1.13
FilterByContext .
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
type ContentType ¶
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 Filter ¶ added in v0.1.4
type Filter []FilterComponent
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)
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 (*Item) AddActions ¶
AddActions adds many Actions to this Item
func (*Item) AddProperties ¶
func (i *Item) AddProperties(ps Properties)
AddProperties adds many Properties to this Item
func (*Item) AddProperty ¶
AddProperty add a Property to this Item
func (*Item) DecodeData ¶
func (*Item) EncodeData ¶
type Items ¶
type Items []Item
Items represents a collection of Item
func (Items) Filter ¶
Filter returns a collection of Items that conform to the profided specification
type Link ¶
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 ¶ added in v0.1.4
func MakeFilterLink(fc FilterConfiguration, template string, currentFilter Filter, placeholder string) Link
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 (Meta) DefaultSort ¶ added in v0.1.4
func (Meta) FilterTemplate ¶ added in v0.1.4
func (Meta) MarshalJSON ¶ added in v0.1.4
func (Meta) SearchTemplate ¶ added in v0.1.4
func (Meta) SortTemplate ¶ added in v0.1.4
func (Meta) WithBefore ¶ added in v0.1.4
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 HiddenParameter ¶ added in v0.1.10
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 ResolverFunc ¶
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
type SortComponent ¶ added in v0.1.4
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 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