Documentation
¶
Index ¶
- Constants
- Variables
- type Curie
- type Embeds
- type Link
- type Links
- type Resource
- func (r *Resource) AddCurie(curie *Curie) error
- func (r *Resource) AddEmbed(reltype string, embed *Resource) error
- func (r *Resource) AddLink(reltype string, link *Link) error
- func (r *Resource) MarshalJSON() ([]byte, error)
- func (r *Resource) Self(uri string)
- func (r *Resource) UnmarshalJSON(b []byte) error
Constants ¶
View Source
const ( // NAME is a name link, curie property NAME = "name" // HREF is a href link, curie property HREF = "href" // HREFLANG is a hreflang link property HREFLANG = "hreflang" // TEMPLATED is a templated link, curie property TEMPLATED = "templated" // PROFILE is a profile link property PROFILE = "profile" // TITLE is a title link property TITLE = "title" // TYPE is a type link property TYPE = "type" // DEPRECATION is a deprecation link property DEPRECATION = "deprecation" )
Variables ¶
View Source
var ( // ErrNoCurie is returned when a curied link was added without the associated curie ErrNoCurie = errors.New("Must add curie before adding a curied link") )
Functions ¶
This section is empty.
Types ¶
type Curie ¶
type Curie struct {
Name string `json:"name"`
Href string `json:"href"`
Templated bool `json:"templated"`
}
Curie respresents a curie
type Embeds ¶
Embeds holds embedded relations by reltype
func (*Embeds) MarshalJSON ¶
MarshalJSON marshals embeds
func (*Embeds) UnmarshalJSON ¶
UnmarshalJSON unmarshals embeds
type Link ¶
type Link struct {
Deprecation *string `json:"deprecation,omitempty"`
Href string `json:"href,omitempty"`
HrefLang *string `json:"hreflang,omitempty"`
Profile *string `json:"profile,omitempty"`
Templated bool `json:"templated,omitempty"`
Title *string `json:"title,omitempty"`
Type *string `json:"type,omitempty"`
}
Link represents a link
type Links ¶
type Links struct {
Self *Link `json:"-"`
Curies *[]Curie `json:"curies,omitempty"`
// When serializing to JSON we need to handle this specially
Relations map[string][]*Link
}
Links is a container of Link, mapped by relation, and contains Curies
func (*Links) MarshalJSON ¶
MarshalJSON to marshal Links properly
func (*Links) UnmarshalJSON ¶
UnmarshalJSON to unmarshal links
type Resource ¶
type Resource struct {
Links *Links `json:"_links,omitempty"`
Embeds *Embeds `json:"_embedded,omitempty"`
// When serializing to JSON we need to handle this specially
Data map[string]interface{} `json:"-"`
}
Resource represents a Resource with Links and Embeds with Data
func (*Resource) MarshalJSON ¶
MarshalJSON marshals a resource properly
func (*Resource) UnmarshalJSON ¶
UnmarshalJSON unmarshals embeds
Click to show internal directories.
Click to hide internal directories.