hal: github.com/nvellon/hal Index | Files

package hal

import "github.com/nvellon/hal"

Index

Package Files

hal.go

type CurieHandle Uses

type CurieHandle struct {
    Name string
    *Resource
}
func (c CurieHandle) AddNewLink(rel Relation, href string)

AddNewLink adds a link to the resources_link collection prepended with the curie Name

type Embedded Uses

type Embedded map[Relation]interface{}

func (Embedded) Add Uses

func (e Embedded) Add(rel Relation, r *Resource)

Add appends the resource into the list of embedded resources with the specified relation. r should be a Resource

func (Embedded) AddCollection Uses

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) Del Uses

func (e Embedded) Del(rel Relation)

Del deletes the resources associated with the given relation.

func (Embedded) Set Uses

func (e Embedded) Set(rel Relation, r *Resource)

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 Uses

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 Entry Uses

type Entry map[string]interface{}
type Link LinkAttr
func NewLink(href string, attrs ...LinkAttr) Link

NewLink returns a new Link object.

type LinkAttr Uses

type LinkAttr map[string]interface{}

Link types that store hyperlinks and its attributes.

type LinkCollection Uses

type LinkCollection []Link

type LinkRelations Uses

type LinkRelations map[Relation]interface{}

type Mapper Uses

type Mapper interface {
    GetMap() Entry
}

Mapper is the interface implemented by the objects that can be converted into HAL format.

type Relation Uses

type Relation string

type Resource Uses

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 Uses

func NewResource(p interface{}, selfUri string) *Resource

NewResource creates a Resource object for a given struct and its link.

func (r *Resource) AddLink(rel Relation, l Link)

AddLink appends a Link to the resource. l should be a Link

func (*Resource) AddLinkCollection Uses

func (r *Resource) AddLinkCollection(rel Relation, l LinkCollection)

AddLinkCollection appends a LinkCollection to the resource. l should be a LinkCollection

func (r *Resource) AddNewLink(rel Relation, href string)

AddNewLink appends a new Link object based on the rel and href params.

func (*Resource) Embed Uses

func (r *Resource) Embed(rel Relation, re *Resource)

Embed appends a Resource to the array of embedded resources. re should be a pointer to a Resource

func (*Resource) EmbedCollection Uses

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) GetMap Uses

func (r Resource) GetMap() Entry

Map implements the interface Mapper.

func (Resource) MarshalJSON Uses

func (r Resource) MarshalJSON() ([]byte, error)

MarshalJSON is a Marshaler interface implementation for Resource struct

func (*Resource) RegisterCurie Uses

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 Uses

type ResourceCollection []*Resource

Package hal imports 3 packages (graph) and is imported by 8 packages. Updated 2018-08-14. Refresh now. Tools for package owners.