api

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2021 License: MIT Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultEndpoint

func DefaultEndpoint(c echo.Context) error

DefaultEndpoint returns http.StatusOK if the service is able to respond to requests.

func ErrorResponse

func ErrorResponse(c echo.Context, status int, err error) error

ErrorResponse reports the error and responds with an ErrorObject

func StandardResponse

func StandardResponse(c echo.Context, status int, res interface{}) error

StandardResponse is the default way to respond to API requests

Types

type StatusObject

type StatusObject struct {
	Status    int    `json:"status" binding:"required"`
	Message   string `json:"message" binding:"required"`
	RootError error  `json:"-"`
}

StatusObject is used to report operation status and errors in an API request. The struct can be used as a response object or be treated as an error object

func NewErrorStatus

func NewErrorStatus(s int, e error) StatusObject

NewErrorStatus initializes a new StatusObject from an error

func NewStatus

func NewStatus(s int, m string) StatusObject

NewStatus initializes a new StatusObject

func (*StatusObject) Error

func (so *StatusObject) Error() string

func (*StatusObject) String

func (so *StatusObject) String() string

Jump to

Keyboard shortcuts

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