common

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ParamQueryLimit        = "limit"
	ParamQueryCursor       = "cursor"
	ParamQueryReserveOrder = "reverseOrder"
)
View Source
const StatusInternalError = "internal_error"

Variables

View Source
var (
	ErrLimitInvalid        = errors.New("invalid limit")
	ErrReverseOrderInvalid = errors.New("invalid reverseOrder")
)

Functions

func BindAndValidateRequest

func BindAndValidateRequest(c echo.Context, req Validatable) bool

func ErrorResponse

func ErrorResponse(c echo.Context, status string) error

func NotFoundResponse

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

func QueryLimit

func QueryLimit(c echo.Context) (int, error)

func QueryReverseOrder

func QueryReverseOrder(c echo.Context) (bool, error)

func UUID

func UUID(c echo.Context, param string) (uuid.UUID, error)

UUID parsed uuid from request's path or query. If failed, writes validation error response.

func ValidationErrorItemResponse

func ValidationErrorItemResponse(c echo.Context, field, message string, args ...any) error

func ValidationErrorResponse

func ValidationErrorResponse(c echo.Context, reason any) error

func WrapErrorItem

func WrapErrorItem(item *model.ErrorResponseItem) error

Types

type PaginationQuery

type PaginationQuery struct {
	Limit       int
	Cursor      string
	ReverseSort bool
}

func QueryPagination

func QueryPagination(c echo.Context) (PaginationQuery, error)

type Validatable

type Validatable interface {
	Validate(formats strfmt.Registry) error
}

Jump to

Keyboard shortcuts

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