Back to

Package response

Latest Go to latest

The highest tagged major version is .

Published: Feb 4, 2020 | License: Unlicense | Module:


func NewBadRequestResponse

func NewBadRequestResponse(c echo.Context, message string) error

NewBadRequestResponse sends a bad response with a reason

func NewErrorResponse

func NewErrorResponse(c echo.Context, code int, message string) error

NewErrorResponse sends an error response

func NewErrorResponseWithCode

func NewErrorResponseWithCode(c echo.Context, statusCode int) error

NewErrorResponseWithCode sends an error response with a default message

func NewHTTPError

func NewHTTPError(err error) (int, string)

NewHTTPError extracts an HTTP error code and a message from an error

func NewInternalErrorResponse

func NewInternalErrorResponse(c echo.Context, message string) error

NewInternalErrorResponse sends an internal server error response

func NewNotFoundResponse

func NewNotFoundResponse(c echo.Context) error

NewNotFoundResponse sends a not found response

func NewResponseFromError

func NewResponseFromError(c echo.Context, err error) error

NewResponseFromError sends an error response from an Error

func NewSuccessEmptyResponse

func NewSuccessEmptyResponse(c echo.Context) error

NewSuccessEmptyResponse sends a successful response with a 201 code and empty body

func NewSuccessResponse

func NewSuccessResponse(c echo.Context, data interface{}) error

NewSuccessResponse sends a successful response

func NewSuccessResponseWithCode

func NewSuccessResponseWithCode(c echo.Context, code int, data interface{}) error

NewSuccessResponseWithCode sends a successful response with code

func NewUnauthorizedErrorResponse

func NewUnauthorizedErrorResponse(c echo.Context) error

NewUnauthorizedErrorResponse sends a 401 error response

type HTTPError

type HTTPError struct {
	Code    int
	Message string

HTTPError is an error with an HTTP code

func (HTTPError) Error

func (e HTTPError) Error() string

Error returns the error message of an HTTPError

type ServiceResponse

type ServiceResponse struct {
	Status Status      `json:"status"`
	Data   interface{} `json:"data,omitempty"`

ServiceResponse is a generic service response

type Status

type Status struct {
	Error   bool   `json:"error"`
	Code    int    `json:"code"`
	Message string `json:"message"`
	Version string `json:"version"`

Status is the status of the response

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier