jres

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2019 License: MIT Imports: 2 Imported by: 1

README

JRes

JRes is a JSON response helper to ensure usage of a consistent API structure.

Examples

// Default standard response with 200
jres.OK(w, map[string]string{"test":"data"})

// Add the location it was created at
jres.Created(w, "/api/v1/thing/1", nil)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Accepted

func Accepted(w http.ResponseWriter, data interface{}) error

func BadRequest

func BadRequest(w http.ResponseWriter, msg string) error

func Conflict

func Conflict(w http.ResponseWriter, errors []string) error

func Created

func Created(w http.ResponseWriter, at string, data interface{}) error

func Forbidden

func Forbidden(w http.ResponseWriter) error

func MethodNotAllwed

func MethodNotAllwed(w http.ResponseWriter, errors []string) error

func NoContent

func NoContent(w http.ResponseWriter) error

func NotFound

func NotFound(w http.ResponseWriter, msg string) error

func OK

func OK(w http.ResponseWriter, data interface{}) error

func Redirect

func Redirect(w http.ResponseWriter, to string) error

func Send

func Send(w http.ResponseWriter, status int, data interface{}) error

func ServerError

func ServerError(w http.ResponseWriter) error

func Unauthorized

func Unauthorized(w http.ResponseWriter, data interface{}) error

func UnprocessableEntity

func UnprocessableEntity(w http.ResponseWriter, data interface{}) error

func ValidationError

func ValidationError(w http.ResponseWriter, errors []string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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