Documentation
¶
Index ¶
- Constants
- func BadRequestError(err error, details ...string) *echo.HTTPError
- func ConflictError(err error, details ...string) *echo.HTTPError
- func ExecuteStandardized[REQ any, RES any](c *echo.Context, request *REQ, handlerName string, ...) (resp any, httpErr *echo.HTTPError)
- func ForbiddenError(err error, details ...string) *echo.HTTPError
- func HTTPError(code int, err error, details ...string) *echo.HTTPError
- func InternalError(err error, details ...string) *echo.HTTPError
- func NormalizePage(page, pageSize int) (normalizedPage, normalizedSize, offset int)
- func NotFoundError(err error, details ...string) *echo.HTTPError
- func RequestIDSkipper(skip bool) echomiddleware.Skipper
- func RestLogFieldsExtractor(ctx *echo.Context) map[string]any
- func ServiceUnavailableError(err error, details ...string) *echo.HTTPError
- func UnauthorizedError(err error, details ...string) *echo.HTTPError
- func Wrapper[TREQ any](wrapped func(*echo.Context, *TREQ) (any, *echo.HTTPError)) echo.HandlerFunc
- type APIResponse
- type Config
- type HandlerFunc
- type HandlerResponse
- type Pagination
- type ResponseError
- type Server
Constants ¶
View Source
const ( ErrCodeValidation = "VALIDATION_ERROR" ErrCodeNotFound = "NOT_FOUND" ErrCodeForbidden = "FORBIDDEN" ErrCodeConflict = "CONFLICT" ErrCodeInternal = "INTERNAL_ERROR" ErrCodeBadRequest = "BAD_REQUEST" )
View Source
const ( DefaultPage = 1 DefaultPageSize = 50 MaxPageSize = 100 )
Variables ¶
This section is empty.
Functions ¶
func ExecuteStandardized ¶
func NormalizePage ¶
func RequestIDSkipper ¶
func RequestIDSkipper(skip bool) echomiddleware.Skipper
func ServiceUnavailableError ¶
Types ¶
type APIResponse ¶
type APIResponse[T any] struct { RequestID string `example:"3bf74527-8097-4217-8485-ffe05d16f82e" json:"requestId,omitempty"` Data T `json:"data"` Pagination *Pagination `json:"pagination,omitempty"` }
type HandlerFunc ¶
type HandlerResponse ¶
type HandlerResponse[T any] struct { Data T `json:"data"` Pagination *Pagination `json:"pagination,omitempty"` }
func NewPaginatedResponse ¶
func NewPaginatedResponse[T any](data T, pagination *Pagination) *HandlerResponse[T]
func NewResponse ¶
func NewResponse[T any](data T) *HandlerResponse[T]
type Pagination ¶
type Pagination struct {
Page int `example:"1" json:"page"`
PageSize int `example:"10" json:"pageSize"`
TotalCount int `example:"42" json:"totalCount"`
TotalPages int `example:"5" json:"totalPages"`
}
func NewPagination ¶
func NewPagination(page, pageSize, totalCount int) *Pagination
type ResponseError ¶
type ResponseError struct {
Message string `json:"message"`
}
func (ResponseError) Error ¶
func (e ResponseError) Error() string
Click to show internal directories.
Click to hide internal directories.