Documentation
¶
Index ¶
- 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)
- type ResourceCollection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Embedded ¶ added in v0.2.0
type Embedded map[Relation]interface{}
func (Embedded) Add ¶ added in v0.2.0
Add appends the resource into the list of embedded resources with the specified relation. r should be a Resource
func (Embedded) AddCollection ¶ added in v0.2.0
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 ¶ added in v0.2.0
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 ¶ added in v0.2.0
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 LinkCollection ¶
type LinkCollection []Link
type LinkRelations ¶ added in v0.2.0
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 Mapper
Links LinkRelations
Embedded Embedded
}
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 ¶ added in v0.2.0
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 ¶ added in v0.2.0
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
type ResourceCollection ¶ added in v0.2.0
type ResourceCollection []*Resource