response

package
v0.0.0-...-27e07c4 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultStatusText string = ""

DefaultStatusText is used for substitution with a standard HTTP status text

Variables

This section is empty.

Functions

func Proxy

Proxy constructs a generic API response

Types

type Error

type Error struct {
	Code    int         `json:"code,omitempty"`    // code (use either code or reason)
	Reason  string      `json:"reason,omitempty"`  // reason (use either code or reason)
	Message string      `json:"message"`           // human-readable description
	Details interface{} `json:"details,omitempty"` // public details
	Errors  []Error     `json:"errors,omitempty"`  // detailed errors
	Meta    interface{} `json:"-"`                 // private meta data (excluded from marshalling)
}

Error response body

func (*Error) Error

func (e *Error) Error() string

type Headers

type Headers map[string]string

Headers map

type Response

type Response struct {
	StatusCode int         `json:"statusCode"` // HTTP status code
	Body       interface{} `json:"body"`       // HTTP response body
	Headers    Headers     `json:"headers"`    // HTTP headers
}

Response message

func BadRequest

func BadRequest(message string) Response

BadRequest returns 400 status code

func Conflict

func Conflict(message string) Response

Conflict returns 409 status code

func Created

func Created(body interface{}, location string) Response

Created returns 201 status code

func InternalServerError

func InternalServerError(message string) Response

InternalServerError returns 500 status code

func MethodNotAllowed

func MethodNotAllowed(allow string) Response

MethodNotAllowed returns 405 status code

func NoContent

func NoContent() Response

NoContent returns 204 status code

func NotFound

func NotFound(message string) Response

NotFound returns 404 status code

func OK

func OK(body interface{}, headers Headers) Response

OK returns 200 status code

Jump to

Keyboard shortcuts

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