restful

package
v0.0.0-...-9bd2c4f Latest Latest
Warning

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

Go to latest
Published: May 15, 2018 License: BSD-3-Clause Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	Type    string      `json:"type"`
	Default interface{} `json:"default,omitempty"`
}

type Base

type Base struct {
	Title    string `json:"title"`
	SubTitle string `json:"subTitle"`
}

type DashboardPayload

type DashboardPayload struct {
	Base    Base           `json:"base"`
	Entries []EntriesGroup `json:"entries"`
	Models  []ModelsGroup  `json:"models"`
}

type EntriesGroup

type EntriesGroup struct {
	Name    string  `json:"groupName"`
	Desc    string  `json:"groupDesc,omitempty"`
	Entries []Entry `json:"entries"`
}

type Entry

type Entry struct {
	Type       string `json:"type"`
	API        string `json:"api"`
	Desc       string `json:"desc,omitempty"`
	Deprecated bool   `json:"deprecated,omitempty"`
}

type Error

type Error struct {
	Status int    `json:"status"`
	Title  string `json:"title"`
	Detail string `json:"detail"`
	Source string `json:"source"`
}

func Error401Unauthorized

func Error401Unauthorized() *Error

create error types

func Error403Forbidden

func Error403Forbidden() *Error

func Error404NotFound

func Error404NotFound() *Error

func Error405MethodNotAllowed

func Error405MethodNotAllowed() *Error

func Error408RequestTimeout

func Error408RequestTimeout() *Error

func Error409Conflict

func Error409Conflict() *Error

func Error415UnsupportedMediaType

func Error415UnsupportedMediaType() *Error

func Error500InternalServerError

func Error500InternalServerError() *Error

func Error502BadGateway

func Error502BadGateway() *Error

func Error503ServiceUnavailable

func Error503ServiceUnavailable() *Error

type ErrorResource

type ErrorResource struct {
	*Resource
	Errors []*Error `json:"errors"`
}

func NewErrorResource

func NewErrorResource(errors ...*Error) *ErrorResource

type Model

type Model struct {
	Name       string               `json:"name"`
	Attributes map[string]Attribute `json:"attributes"`
}

type ModelsGroup

type ModelsGroup struct {
	Name   string  `json:"groupName"`
	Desc   string  `json:"groupDesc,omitempty"`
	Models []Model `json:"models"`
}

type Request

type Request struct {
	Resources interface{} `json:"data"`
	Included  interface{} `json:"included"`
	// contains filtered or unexported fields
}

func NewRequest

func NewRequest() *Request

func Reader

func Reader(r *http.Request) *Request

func (*Request) Receive

func (req *Request) Receive() *Request

func (*Request) WithIncluded

func (req *Request) WithIncluded(resources ...RestfulResource) *Request

func (*Request) WithResource

func (req *Request) WithResource(resource RestfulResource) *Request

func (*Request) WithResourceArr

func (req *Request) WithResourceArr(resources interface{}) *Request

func (*Request) WithResources

func (req *Request) WithResources(resources ...RestfulResource) *Request

type Response

type Response struct {
	Resources interface{} `json:"data"`
	Links     *Links      `json:"links"`
	// contains filtered or unexported fields
}

func NewResponse

func NewResponse() *Response

func Writer

func Writer(w http.ResponseWriter) *Response

func (*Response) Send

func (res *Response) Send()

func (*Response) WithHeader

func (res *Response) WithHeader(key, val string) *Response
func (res *Response) WithLinks(links *Links) *Response

func (*Response) WithResource

func (res *Response) WithResource(resource RestfulResource) *Response

func (*Response) WithResourceArr

func (res *Response) WithResourceArr(resources interface{}) *Response

func (*Response) WithResources

func (res *Response) WithResources(resources ...RestfulResource) *Response

func (*Response) WithStatus

func (res *Response) WithStatus(status int) *Response

type RestfulResource

type RestfulResource interface {
	GetType() string
	GetId() string
	GetRelationships() map[string]*Relationship
}

Jump to

Keyboard shortcuts

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