jsonapi

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2020 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HeaderAcceptLanguage is the HTTP header name for accepted languages.
	HeaderAcceptLanguage = "Accept-Language"
	// HeaderContentLanguage is the HTTP header name for the content language.
	HeaderContentLanguage = "Content-Language"
)
View Source
const (
	// QueryParamPageTotal is the query parameter that marks to get total number instances / pages for the collection.
	QueryParamPageTotal string = "page[total]"
	// QueryParamLinks is the query parameter that marks to marshal object links.
	QueryParamLinks string = "links"
)

Variables

This section is empty.

Functions

func AcceptMediaTypeMid

func AcceptMediaTypeMid(next httprouter.Handle) httprouter.Handle

AcceptMediaTypeMid is the middleware that checks if the request contains Header "Accept: application/vnd.api+json".

func New

New creates new jsonapi Handler.

func UnsupportedMediaTypeMid

func UnsupportedMediaTypeMid(next httprouter.Handle) httprouter.Handle

UnsupportedMediaTypeMid is the middleware that checks if the request contains Header "Content-Type" with media type different then `application/vnd.api+json`

Types

type Handler

type Handler struct {
	Config *config.Router
	// contains filtered or unexported fields
}

Handler is the neuron gateway handler that implements https://jsonapi.org server routes for neuron models.

func (*Handler) Router

func (h *Handler) Router() *httprouter.Router

Router implements handler.Handler interface.

func (*Handler) SetModelRoutes

func (h *Handler) SetModelRoutes(model interface{}) error

SetModelRoutes sets the routes for the provided 'model'. The model must be registered within the controller provided in the Handler creator. Implements router.Router interface.

func (*Handler) SetRoutes

func (h *Handler) SetRoutes() (err error)

SetRoutes sets the JSONAPI specific routes for all model registered within the Handler's controller. Implements router.Router interface.

Jump to

Keyboard shortcuts

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