Documentation ¶
Index ¶
- func AddErrorMessage(k string, v func(validator.FieldError) string)
- func Error(c echo.Context, options ...AppOpt) error
- func ErrorCode(c echo.Context, code int, options ...AppOpt) error
- func NewStd(code, msg string) error
- func NewStdErr(code string, err error) error
- func NewValidationErrors(validations validator.ValidationErrors) []validationError
- func Success(c echo.Context, options ...AppOpt) error
- type App
- type AppOpt
- type Std
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddErrorMessage ¶ added in v0.2.0
AddErrorMessage add or replace error message mapping to bag from given key value.
func Error ¶
Error return echo framework json response with standard error response as the structure.
func ErrorCode ¶
ErrorCode return echo framework json response with standard error response as the structure and use given code as response status code.
func NewValidationErrors ¶ added in v0.2.0
func NewValidationErrors(validations validator.ValidationErrors) []validationError
NewValidationErrors return ready to display error validations.
Types ¶
type App ¶ added in v0.2.0
type App struct { Code string `json:"code,omitempty"` Message string `json:"message"` Data any `json:"data,omitempty"` Error any `json:"error,omitempty"` Pagination any `json:"pagination,omitempty"` // Pagination additional field when need to serve many Data and want to show pagination info. }
App standard success response that may be used in every response for all handlers.
type AppOpt ¶ added in v0.2.0
type AppOpt func(*App)
AppOpt an option signature for App response.
func WithData ¶ added in v0.2.0
WithData option to add the given data to success response as `data` field.
func WithErr ¶ added in v0.2.0
WithErr option to add given detail to error response as `error` field.
func WithPaginate ¶ added in v0.2.0
WithPaginate option to add the given paginate to success response as `pagination` field.