ginx

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2024 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitCounterCode

func InitCounterCode(opt prometheus.CounterOpts)

InitCounterCode 初始化错误码统计:prometheus错误码统计

func WrapError

func WrapError(fn func(ctx *gin.Context) (Result, error),
	l logger.Logger,
	lm LogMessage) gin.HandlerFunc

WrapError 统一处理错误日志打印

func WrapReq

func WrapReq[T any](fn func(ctx *gin.Context, req T) (Result, error),
	l logger.Logger,
	lm LogMessage) gin.HandlerFunc

WrapReq 统一处理请求体bind/错误日志打印

func WrapReqAndToken

func WrapReqAndToken[T any, C jwt.Claims](fn func(ctx *gin.Context, req T, uc C) (Result, error),
	l logger.Logger,
	lm LogMessage,
	ctxKey string) gin.HandlerFunc

WrapReqAndToken 统一处理请求体bind/ctx中取值/错误日志打印

func WrapToken

func WrapToken[C jwt.Claims](
	fn func(ctx *gin.Context, uc C) (Result, error),
	l logger.Logger,
	lm LogMessage,
	ctxKey string) gin.HandlerFunc

WrapToken 统一处理ctx中取值/错误日志打印

Types

type LogMessage

type LogMessage struct {
	Method  string
	Message string
}

type Result

type Result struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
	Data any    `json:"data"`
}

Directories

Path Synopsis
middleware

Jump to

Keyboard shortcuts

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