Documentation ¶
Overview ¶
Package hypermedia provides helpers for parsing hypermedia links in resources and expanding the links to make further requests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HALResource ¶
type HALResource struct { Links Links `json:"_links"` // contains filtered or unexported fields }
HALResource is a resource with hypermedia specified as JSON HAL.
http://stateless.co/hal_specification.html
func (*HALResource) Rels ¶
func (r *HALResource) Rels() Relations
Rels gets the link relations from the HALResource's Links field.
type Hyperlink ¶
type Hyperlink string
Hyperlink is a string url. If it is a uri template, it can be converted to a full URL with Expand().
type HypermediaResource ¶
type HypermediaResource interface {
Rels() Relations
}
A HypermediaResource has link relations for next actions of a resource.
type Link ¶
type Link struct {
Href Hyperlink `json:"href"`
}
Link represents a single link in a HALResource.
type Links ¶
Links is a collection of Link objects in a HALResource. Note that the HAL spec allows single link objects or an array of link objects. Sawyer currently only supports single link objects.
type Relations ¶
Relations is a map of keys that point to Hyperlink objects.
func HyperFieldDecoder ¶
func HyperFieldDecoder(res interface{}) Relations
The HyperFieldDecoder gets link relations from a resource by reflecting on its Hyperlink properties. The relation name is taken either from the name of the field, or a "rel" struct tag.
type Foo struct { Url Hyperlink `rel:"self" json:"url"` CommentsUrl Hyperlink `rel:"comments" json:"comments_url"` }
func HypermediaDecoder ¶
func HypermediaDecoder(res HypermediaResource) Relations
The HypermediaDecoder gets the link relations from any HypermediaResource.