echox

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeJSON

func EncodeJSON(ctx echo.Context, code int, i interface{}) error

EncodeJSON sends a JSON response with status code.

func ParamDate

func ParamDate(ctx echo.Context) types.Date

ParamDate returns the value of the parameter :date

func ParamID

func ParamID(ctx echo.Context) uint64

ParamID returns the value of the parameter :id

func ParseDate

func ParseDate(v string) types.Date

ParseDate parse the given string as date.

func QueryDate

func QueryDate(ctx echo.Context, key string) types.Date

QueryDate returns the given query as date.

func QueryDateOrNow

func QueryDateOrNow(ctx echo.Context, key string) types.Date

QueryDateOrNow returns the given query as date and if the date is not valid, current date will be used.

func QueryPage

func QueryPage(ctx echo.Context) uint64

QueryPage returns the page query.

func QueryScopes

func QueryScopes(ctx echo.Context) types.Strings

QueryScopes returns parsed scopes.

Types

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

Error is the representation of the error wrapper.

func ErrorWrapper

func ErrorWrapper(code int, message string) Error

ErrorWrapper is wrapping code & error message.

func (*Error) Error

func (err *Error) Error() string

Error

func (Error) JSON

func (err Error) JSON(ctx echo.Context) error

JSON returns json encoding of Error.

type OK

type OK struct {
	Code        int         `json:"code"`
	CodeIfEmpty int         `json:"-"`
	Meta        types.Map   `json:"meta"`
	Data        interface{} `json:"data"`
}

OK is the representation of the response wrapper.

func Index

func Index(values interface{}, n int) OK

Index is a wrapper that returns a list of values as JSON.

func Show

func Show(val interface{}, err error) OK

Show is a wrapper that returns a value as JSON.

func (OK) JSON

func (ok OK) JSON(ctx echo.Context) error

JSON returns json encoding of OK.

Jump to

Keyboard shortcuts

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