render

package
v0.0.0-...-b144d23 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package render provides JSON API responder and decoder that integrates with https://github.com/go-chi/render it also provides a `DefaultResponder` and `DefaultDecoder` for easy integration

Index

Constants

View Source
const (
	ContentTypeJSONAPI chi_render.ContentType = iota + 1000
)

Variables

This section is empty.

Functions

func DecodeJSONAPI

func DecodeJSONAPI(r io.Reader, v interface{}) error

func DefaultDecoder

func DefaultDecoder(r *http.Request, v interface{}) error

DefaultDecoder decodes JSON API delegates any other content type to github.con/go-chi/render

func DefaultResponder

func DefaultResponder(w http.ResponseWriter, r *http.Request, v interface{})

Respond handles JSON API responses and delegates any other content type to github.com/go-chi/render automatically setting the Content-Type based on request headers

func GetAcceptedContentType

func GetAcceptedContentType(r *http.Request) chi_render.ContentType

func GetContentType

func GetContentType(s string) chi_render.ContentType

GetContentType extends go-ci/render to support application/vnd.api+json

func GetRequestContentType

func GetRequestContentType(r *http.Request) chi_render.ContentType

GetRequestContentType is a helper function that returns ContentType based on context or request headers.

func JSONAPI

func JSONAPI(w http.ResponseWriter, r *http.Request, v interface{})

JSONAPI marshals `v` to JSONAPI, automatically setting Content-Type as application/vnd.api+json

Types

This section is empty.

Jump to

Keyboard shortcuts

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