Documentation ¶
Index ¶
- type CurieHandle
- type Embedded
- type Entry
- type Link
- type LinkAttr
- type LinkCollection
- type LinkRelations
- type Mapper
- type Relation
- type Resource
- func (r *Resource) AddLink(rel Relation, l Link)
- func (r *Resource) AddLinkCollection(rel Relation, l LinkCollection)
- func (r *Resource) AddNewLink(rel Relation, href string)
- func (r *Resource) Embed(rel Relation, re *Resource)
- func (r *Resource) EmbedCollection(rel Relation, re ResourceCollection)
- func (r Resource) GetMap() Entry
- func (r Resource) MarshalJSON() ([]byte, error)
- func (r *Resource) RegisterCurie(name, href string, templated bool) *CurieHandle
- type ResourceCollection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CurieHandle ¶ added in v0.3.0
func (CurieHandle) AddNewLink ¶ added in v0.3.0
func (c CurieHandle) AddNewLink(rel Relation, href string)
AddNewLink adds a link to the resources_link collection prepended with the curie Name
type Embedded ¶
type Embedded map[Relation]interface{}
func (Embedded) Add ¶
Add appends the resource into the list of embedded resources with the specified relation. r should be a Resource
func (Embedded) AddCollection ¶
func (e Embedded) AddCollection(rel Relation, r ResourceCollection)
AddCollection appends the resource into the list of embedded resources with the specified relation. r should be a ResourceCollection
func (Embedded) Set ¶
Set sets the resource into the list of embedded resources with the specified relation. It replaces any existing resources associated with the relation. r should be a pointer to a Resource
func (Embedded) SetCollection ¶
func (e Embedded) SetCollection(rel Relation, r ResourceCollection)
Set sets the resource into the list of embedded resources with the specified relation. It replaces any existing resources associated with the relation. r should be a ResourceCollection
type LinkAttr ¶
type LinkAttr map[string]interface{}
Link types that store hyperlinks and its attributes.
type LinkCollection ¶
type LinkCollection []Link
type LinkRelations ¶
type LinkRelations map[Relation]interface{}
type Mapper ¶
type Mapper interface {
GetMap() Entry
}
Mapper is the interface implemented by the objects that can be converted into HAL format.
type Resource ¶
type Resource struct { Payload interface{} Links LinkRelations Embedded Embedded Curies map[string]*CurieHandle }
Resource is a struct that stores a resource data. It represents a converted object in the HAL spec by containing all its fields and also a set of related links and a sub-set of recursively related resources.
func NewResource ¶
NewResource creates a Resource object for a given struct and its link.
func (*Resource) AddLinkCollection ¶
func (r *Resource) AddLinkCollection(rel Relation, l LinkCollection)
AddLinkCollection appends a LinkCollection to the resource. l should be a LinkCollection
func (*Resource) AddNewLink ¶
AddNewLink appends a new Link object based on the rel and href params.
func (*Resource) Embed ¶
Embed appends a Resource to the array of embedded resources. re should be a pointer to a Resource
func (*Resource) EmbedCollection ¶
func (r *Resource) EmbedCollection(rel Relation, re ResourceCollection)
EmbedCollection appends a ResourceCollection to the array of embedded resources. re should be a ResourceCollection
func (Resource) MarshalJSON ¶
MarshalJSON is a Marshaler interface implementation for Resource struct
func (*Resource) RegisterCurie ¶ added in v0.3.0
func (r *Resource) RegisterCurie(name, href string, templated bool) *CurieHandle
RegisterCurie adds a Link relation of type 'curies' and returns a CurieHandle to allow users to fluently add new links that have this curie relation definition
type ResourceCollection ¶
type ResourceCollection []*Resource