resource

package module
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 10 Imported by: 0

README

rest-resource

Library for creating, transmitting, and consuming REST resources containing links (HATEOAS)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConstructUriFromTemplate added in v0.3.0

func ConstructUriFromTemplate(template string, parameters ...interface{}) string

Types

type ConfigureLink struct {
	// contains filtered or unexported fields
}

func (ConfigureLink) Parameter added in v0.3.0

func (cl ConfigureLink) Parameter(name string, parameterOptions ...option.Option) ConfigureLink

func (ConfigureLink) ResponseCodes added in v0.3.0

func (cl ConfigureLink) ResponseCodes(statuses ...int) ConfigureLink

func (ConfigureLink) ResponseSchema added in v0.5.0

func (cl ConfigureLink) ResponseSchema(responseSchema string) ConfigureLink

type ConfigureMap

type ConfigureMap struct {
	// contains filtered or unexported fields
}

func (*ConfigureMap) EndMap

func (cm *ConfigureMap) EndMap() *Resource

func (*ConfigureMap) Exclude

func (cm *ConfigureMap) Exclude(fieldName string) *ConfigureMap

func (*ConfigureMap) Map

func (cm *ConfigureMap) Map(fieldName string, mapOptions ...option.Option) *ConfigureMap

func (*ConfigureMap) MapAll

func (cm *ConfigureMap) MapAll() *ConfigureMap

func (*ConfigureMap) MapChild

func (cm *ConfigureMap) MapChild(fieldName string) *ConfigureMap

type EmbeddedResources

type EmbeddedResources map[string]interface{}

type FormattedData

type FormattedData struct {
	Value interface{}
	// contains filtered or unexported fields
}

func (FormattedData) FormattedString

func (fd FormattedData) FormattedString() string

func (FormattedData) MarshalJSON

func (fd FormattedData) MarshalJSON() ([]byte, error)
type Link struct {
	Href           string
	Verb           string
	IsTemplated    bool
	Parameters     []LinkParameter
	ResponseSchema string
	ResponseCodes  []int
}

func (*Link) MarshalJSON

func (l *Link) MarshalJSON() ([]byte, error)

type LinkData

type LinkData map[string]*Link

type LinkParameter

type LinkParameter struct {
	Name         string
	DefaultValue string
	ListOfValues string
	DataType     string
}

type MappedData

type MappedData map[string]interface{}

type Resource

type Resource struct {
	Schema   string
	Values   MappedData
	Links    LinkData
	Embedded EmbeddedResources
}

func NewResource

func NewResource(schema ...string) Resource

func (*Resource) Data

func (r *Resource) Data(name string, value interface{}, mapOptions ...option.Option) *Resource

func (*Resource) EmbedResource

func (r *Resource) EmbedResource(name string, resource Resource) *Resource

func (*Resource) EmbedResources

func (r *Resource) EmbedResources(name string, resources []Resource) *Resource
func (r *Resource) Link(name string, href string, linkOptions ...option.Option) ConfigureLink

func (*Resource) MapAllDataFrom

func (r *Resource) MapAllDataFrom(source interface{}) *Resource

func (*Resource) MapChild

func (r *Resource) MapChild(fieldName string, source interface{}) *ConfigureMap

func (*Resource) MapDataFrom

func (r *Resource) MapDataFrom(source interface{}) *ConfigureMap

func (Resource) MarshalXML

func (r Resource) MarshalXML(e *xml.Encoder, _ xml.StartElement) error

func (*Resource) Uri added in v0.3.0

func (r *Resource) Uri(href string) *Resource

type ResponseCode added in v0.3.0

type ResponseCode struct {
	Status      int
	Description string
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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