handler

package
v1.7.1-RC2 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindAndCheck

func BindAndCheck(ctx *gin.Context, data any) bool

BindAndCheck bind request and check

func BindAndCheckReturnErr

func BindAndCheckReturnErr(ctx *gin.Context, data any) (errFields []*validator.FormErrorField)

BindAndCheckReturnErr bind request and check

func GetEnableShortID

func GetEnableShortID(ctx context.Context) bool

GetEnableShortID get language from header

func GetLangByCtx

func GetLangByCtx(ctx context.Context) i18n.Language

GetLangByCtx get language from header

func HandleResponse

func HandleResponse(ctx *gin.Context, err error, data any)

HandleResponse Handle response body

Types

type RespBody

type RespBody struct {
	// http code
	Code int `json:"code"`
	// reason key
	Reason string `json:"reason"`
	// response message
	Message string `json:"msg"`
	// response data
	Data any `json:"data"`
}

RespBody response body.

func NewRespBody

func NewRespBody(code int, reason string) *RespBody

NewRespBody new response body

func NewRespBodyData

func NewRespBodyData(code int, reason string, data any) *RespBody

NewRespBodyData new response body with data

func NewRespBodyFromError

func NewRespBodyFromError(e *errors.Error) *RespBody

NewRespBodyFromError new response body from error

func (*RespBody) TrMsg

func (r *RespBody) TrMsg(lang i18n.Language) *RespBody

TrMsg translate the reason cause as a message

Jump to

Keyboard shortcuts

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