gin_util

package
v0.2.8 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	CLAIMS = "claims"
	STATUS = "STATUS"
	RESULT = "RESULT"

	// http header
	X_LANGUAGE  = "X-Language" // 当前语言
	X_ORG_ID    = "X-Org-Id"   // 当前组织
	X_CLIENT_ID = "X-Client-Id"

	// gin.Context
	USER_ID   = "USER_ID"   // 当前用户
	IS_ADMIN  = "IS_ADMIN"  // USER_ID是否当前组织X_ORG_ID的内置管理员角色
	IS_SYSTEM = "IS_SYSTEM" // 当前组织X_ORG_ID是否是【系统】

	// openapi相关
	APP_ID   = "APP_ID"
	APP_TYPE = "APP_TYPE"

	ANSWER = "ANSWER"

	// OAuth相关
	OAUTH_SCOPE     = "SCOPE"
	OAUTH_CLIENT_ID = "OAuth_Client_ID"
)

gin.Contex key

View Source
const (
	PageNo   = "pageNo"
	PageSize = "pageSize"
)

http common query key

Variables

This section is empty.

Functions

func Bind

func Bind(ctx *gin.Context, param iChecker) bool

func BindForm

func BindForm(ctx *gin.Context, param iChecker) bool

func BindQuery

func BindQuery(ctx *gin.Context, param iChecker) bool

func BindUri

func BindUri(ctx *gin.Context, param iChecker) bool

func I18nCode

func I18nCode(ctx *gin.Context, code err_code.Code, args ...string) string

func I18nCodeOrKey

func I18nCodeOrKey(ctx *gin.Context, code err_code.Code, key string, args ...string) string

func I18nKey

func I18nKey(ctx *gin.Context, key string, args ...string) string

func InitValidator

func InitValidator() error

func Response

func Response(ctx *gin.Context, data interface{}, err error)

Response 返回200与data信息,或者400与err信息,err有i18n

func ResponseDetail

func ResponseDetail(ctx *gin.Context, httpStatus int, code codes.Code, data interface{}, msg string)

ResponseDetail 直接返回httpStatus/code/data/msg,msg无i18n

func ResponseErr

func ResponseErr(ctx *gin.Context, err error)

ResponseDetail 返回400与err信息,err有i18n

func ResponseErrCodeKey

func ResponseErrCodeKey(ctx *gin.Context, code err_code.Code, textKey string, args ...string)

ResponseErrCodeKey 返回400/code与错误信息,code/key有i18n

func ResponseErrCodeKeyWithStatus

func ResponseErrCodeKeyWithStatus(ctx *gin.Context, httpStatus int, code err_code.Code, textKey string, args ...string)

ResponseErrCodeKey 返回httpStatus/code与错误信息,code/key有i18n

func ResponseErrWithStatus

func ResponseErrWithStatus(ctx *gin.Context, httpStatus int, err error)

ResponseDetail 返回httpStatus与err信息,err有i18n

func ResponseOK

func ResponseOK(ctx *gin.Context)

ResponseOK 返回200

func ResponseOKWithData

func ResponseOKWithData(ctx *gin.Context, data interface{})

ResponseOKWithData 返回200与data信息

func ResponseRawByte added in v0.2.5

func ResponseRawByte(ctx *gin.Context, httpStatus int, data []byte)

ResponseRawByte 直接返回[]byte数据

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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