handler

package
v0.0.0-...-883d24b Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2023 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 interface{}) bool

BindAndCheck bind request and check

func BindAndCheckReturnErr

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

BindAndCheckReturnErr bind request and check

func GetEnableShortID

func GetEnableShortID(ctx context.Context) bool

GetEnableShortID get language from header

func GetLang

func GetLang(ctx *gin.Context) i18n.Language

GetLang 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 interface{})

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 interface{} `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 interface{}) *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