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 ¶
Types ¶
type CachedResource ¶
A CachedResource is capable of caching the relations locally, so that multiple accesses don't require parsing it again.
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) HypermediaRels ¶
func (r *HALResource) HypermediaRels(rels Relations)
HypermediaRels implements the HypermediaResource interface by getting the Relations from the Links property.
type HyperfieldResource ¶
type HyperfieldResource interface {
HyperfieldRels()
}
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 {
HypermediaRels(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 HyperFieldRelations ¶
The HyperFieldRelations 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 HyperHeaderRelations ¶
TODO: need a full link header parser for http://tools.ietf.org/html/rfc5988