Documentation ¶
Overview ¶
Package jsonhal provides structs and methods to easily wrap your own data in a HAL compatible struct with support for hyperlinks and embedded resources HAL specification: http://stateless.co/hal_specification.html
Index ¶
- type EmbedGetter
- type EmbedSetter
- type Embedded
- type Embedder
- type Hal
- func (h *Hal) CountEmbedded(name string) (int, error)
- func (h *Hal) DecodeEmbedded(name string, result interface{}) (err error)
- func (h *Hal) DeleteEmbedded(name string)
- func (h *Hal) DeleteLink(name string)
- func (h *Hal) GetEmbedded(name string) (Embedded, error)
- func (h *Hal) GetLink(name string) (*Link, error)
- func (h *Hal) SetEmbedded(name string, embedded Embedded)
- func (h *Hal) SetLink(name, href, title string)
- type Link
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EmbedGetter ¶
EmbedGetter is the interface that wraps the basic getEmbedded method.
GetEmbedded returns a slice of embedded resources by name or error
type EmbedSetter ¶
EmbedSetter is the interface that wraps the basic setEmbedded method.
SetEmbedded adds a slice of objects under a named key in the embedded map
type Embedder ¶
type Embedder interface { EmbedSetter EmbedGetter }
Embedder is the interface that wraps the basic setEmbedded and getEmbedded methods.
type Hal ¶
type Hal struct { Links map[string]*Link `json:"_links,omitempty" mapstructure:"_links"` Embedded map[string]Embedded `json:"_embedded,omitempty" mapstructure:"_embedded"` // contains filtered or unexported fields }
Hal is used for composition, include it as anonymous field in your structs
func (*Hal) CountEmbedded ¶
CountEmbedded counts number of embedded items
func (*Hal) DecodeEmbedded ¶
DecodeEmbedded decodes embedded objects into a struct
func (*Hal) DeleteEmbedded ¶
DeleteEmbedded removes an embedded resource named name if it is found
func (*Hal) DeleteLink ¶
DeleteLink removes a link named name if it is found
func (*Hal) GetEmbedded ¶
GetEmbedded returns a slice of embedded resources by name or error
func (*Hal) SetEmbedded ¶
SetEmbedded adds a slice of objects under a named key in the embedded map