Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddErrorMessage ¶
AddErrorMessage add or replace error message mapping to bag from given key value.
func NewValidationErrors ¶
func NewValidationErrors(validations validator.ValidationErrors) []validationError
NewValidationErrors return ready to display error validations.
Types ¶
type AppError ¶
type AppError struct { Code string `json:"code"` Message string `json:"message"` Error any `json:"error,omitempty"` }
AppError standard error response that may be used in every response for all handlers.
type AppErrorOption ¶
type AppErrorOption func(*AppError)
AppErrorOption an option for AppError response.
func WithErr ¶
func WithErr(err error) AppErrorOption
WithErr option to add given detail to error response as `error` field.
type AppSuccess ¶
type AppSuccess struct { Message string `json:"message"` Data any `json:"data,omitempty"` Pagination any `json:"pagination,omitempty"` // Pagination additional field when need to serve many Data and want to show pagination info. }
AppSuccess standard success response that may be used in every response for all handlers.
type AppSuccessOption ¶
type AppSuccessOption func(*AppSuccess)
AppSuccessOption an option for AppSuccess response.
func WithData ¶
func WithData(data any) AppSuccessOption
WithData option to add the given data to success response as `data` field.
func WithPaginate ¶
func WithPaginate(paginate any) AppSuccessOption
WithPaginate option to add the given paginate to success response as `pagination` field.