response

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(c *fiber.Ctx, options ...AppErrorOption) error

Error return json response with standard error response as the structure.

func ErrorCode

func ErrorCode(c *fiber.Ctx, code int, options ...AppErrorOption) error

ErrorCode return json response with standard error response as the structure and additionally set the response status code.

func NewValidationErrors

func NewValidationErrors(validations validator.ValidationErrors) []validationError

NewValidationErrors return ready to display error validations.

func Success

func Success(c *fiber.Ctx, options ...SuccessOption) error

Success return json response with standard success response as the structure.

Types

type AppErrorOption

type AppErrorOption func(*appError)

AppErrorOption an option for error response.

func WithErr

func WithErr(err error) AppErrorOption

WithErr option to add given error message to error response as `message` field.

func WithErrCode

func WithErrCode(code string) AppErrorOption

WithErrCode option to add given code to error response as `code` field.

func WithErrDetail

func WithErrDetail(detail any) AppErrorOption

WithErrDetail option to add given detail to error response as `detail` field.

func WithErrMsg

func WithErrMsg(msg string) AppErrorOption

WithErrMsg option to add given message to error response as `message` field.

func WithErrValidation

func WithErrValidation(valid validator.ValidationErrors) AppErrorOption

WithErrValidation option to add given valid to error response as `detail` field.

type SuccessOption

type SuccessOption func(*appSuccess)

SuccessOption an option for success response.

func WithData

func WithData(data any) SuccessOption

WithData option to add the given data to success response as `data` field.

func WithMeta

func WithMeta(meta any) SuccessOption

WithMeta option to add the given meta to success response as `meta` field.

func WithMsg

func WithMsg(msg string) SuccessOption

WithMsg option to add given msg to success response as `message` field.

Jump to

Keyboard shortcuts

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