Documentation
¶
Index ¶
- Constants
- func Accept(typ string) func(*http.Request)
- func AcceptLanguage(spec string) func(*http.Request)
- 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 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 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(f func(Action) bool) Actions
- func (as Actions) FilterByRel(rel string) Actions
- func (as Actions) Find(f 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
- 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 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(isSatisfiedBy func(Item) bool) Items
- func (is Items) Find(isSatisfiedBy 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 Parameter
- type Parameters
- type Properties
- type Property
- type Resolver
- type ResolverFunc
- type SelectOption
- type SelectOptions
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" )
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 ActionRelEquals ¶
func ExternalHost ¶
func ExternalPath ¶
func ExternalScheme ¶
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 ¶
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"`
}
Action .
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 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"`
Accept string `json:"accept,omitempty"`
AcceptLanguage string `json:"accept-language,omitempty"`
}
Link .
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 ¶
type Parameters ¶
type Parameters []Parameter
Parameters .
func (Parameters) FindByName ¶
func (as Parameters) FindByName(name string) (Parameter, bool)
FindByName .
type Properties ¶
type Properties []Property
Properties is a collection of Property
func (Properties) Find ¶
func (ps Properties) Find(name string) (Property, bool)
Find returns a Property by name
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 []SelectOption `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)