web

package
v1.1.64 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: MIT Imports: 7 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorResponse

func ErrorResponse(c *gin.Context, code int, message string, causes ...Cause)

func InternalErrorResponse

func InternalErrorResponse(c *gin.Context, err error, logMessage string, v ...interface{})

func NewJSONValidator

func NewJSONValidator() *validator.Validate

func RegisterValidation

func RegisterValidation(tag string, fn func(fl validator.FieldLevel) bool) error

func SuccessResponse

func SuccessResponse(c *gin.Context, message string)

func ValidationErrorResponse

func ValidationErrorResponse(c *gin.Context, causes ...Cause)

Types

type Cause

type Cause struct {
	Field string `json:"field"`
	Code  string `json:"code"`
}

func BindBodyForm

func BindBodyForm(c *gin.Context, val interface{}) (bool, []Cause)

func BindBodyJSON

func BindBodyJSON(c *gin.Context, val interface{}) (bool, []Cause)

func BindHeaders

func BindHeaders(c *gin.Context, val interface{}) (bool, []Cause)

func BindUri

func BindUri(c *gin.Context, val interface{}) (bool, []Cause)

func NewCause

func NewCause(field, code string) Cause

func ValidateStruct

func ValidateStruct(s interface{}) (bool, []Cause)

func ValidateStructWith

func ValidateStructWith(v *validator.Validate, s interface{}) (bool, []Cause)

func ValidateVar

func ValidateVar(name string, value interface{}, tag string) (bool, []Cause)

func ValidateVarWith

func ValidateVarWith(v *validator.Validate, name string, value interface{}, tag string) (bool, []Cause)

type GenericErrorResponse

type GenericErrorResponse struct {
	Status  string  `json:"status"`
	Message string  `json:"message"`
	Causes  []Cause `json:"causes,omitempty"`
}

type GenericResponse

type GenericResponse struct {
	Status  string `json:"status"`
	Message string `json:"message"`
}

Jump to

Keyboard shortcuts

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