response

package
v6.0.0-...-6862f37 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorResponse

func ErrorResponse(w http.ResponseWriter, r *http.Request, err error)

ErrorResponse creates {error: message} json body and responds with error code

func ErrorResponseWithFields

func ErrorResponseWithFields(w http.ResponseWriter, r *http.Request, err error, props map[string][]error, code int)

ErrorResponseWithFields creates error with props

func ErrorResponseWithStatus

func ErrorResponseWithStatus(w http.ResponseWriter, r *http.Request, err error, code int)

ErrorResponseWithStatus creates {error: message} json body and responds with error code

func ForbiddenResponse

func ForbiddenResponse(w http.ResponseWriter, r *http.Request, message string)

ForbiddenResponse creates empty json body and responds with 403 code

func JSONResponse

func JSONResponse(w http.ResponseWriter, r *http.Request, data interface{})

JSONResponse creates json body

func NotFoundResponse

func NotFoundResponse(w http.ResponseWriter, r *http.Request, message string)

NotFoundResponse creates empty json body and responds with 404 code

func UnauthorizedResponse

func UnauthorizedResponse(w http.ResponseWriter, r *http.Request)

UnauthorizedResponse creates empty json body and responds with 401 code

Types

type ErrStatusedResponse

type ErrStatusedResponse struct {
	Code    int
	Message string
}

ErrStatusedResponse type

func ErrBadRequest

func ErrBadRequest(message string) *ErrStatusedResponse

ErrBadRequest func

func ErrConflict

func ErrConflict(message string) *ErrStatusedResponse

ErrConflict func

func ErrInternalServer

func ErrInternalServer(message string) *ErrStatusedResponse

ErrInternalServer func

func ErrNotFound

func ErrNotFound(message string) *ErrStatusedResponse

ErrNotFound func

func (*ErrStatusedResponse) Error

func (e *ErrStatusedResponse) Error() string

Jump to

Keyboard shortcuts

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