resource

package
v0.0.0-...-a57bf8e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Getting

type Getting interface {
	Go(u string) (*Resource, error)
}

Getting interface represents the getting client object.

type Representor

type Representor interface {
	GetBody() interface{}
	GetLink(rt string) (*link.Link, error)
	GetLinks(rt string) []link.Link
}

Representor interface represents the representation of the body of the request or response.

type Resource

type Resource struct {
	Client      Getting
	URI         *url.URL
	ContentType string
	Representor Representor

	Variables map[string]string
	// contains filtered or unexported fields
}

Resource represents endpoint on a server. The endpoint has a uri, you might for example be able to GET its presentation. A resource may also have a list of links on them, pointing to other resources.

func New

func New(c Getting, u *url.URL) *Resource

New creates a new Resource object.

func (*Resource) Follow

func (r *Resource) Follow(rt string, v map[string]string) (*Resource, error)

Follow follows a relationship, based on its reltype. For example, this might be 'alternate', 'item', 'edit', or a custom url-based one.

func (*Resource) Get

func (r *Resource) Get() (interface{}, error)

Get fetches the resource representation.

func (*Resource) Go

func (r *Resource) Go(u string) (*Resource, error)

Go resolves a new resource based on a relative URI.

func (r *Resource) Link(rt string) (*link.Link, error)

Link returns a specific link based on its rel.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL