coreMiddleware

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CtxKeyTraceId    = "trace_id"
	CtxKeyActionName = "action_name"
	CtxKeyUid        = "uid"
	CtxKeyMobile     = "mobile"
	CtxKeyIdCard     = "id_card"
)

Variables

This section is empty.

Functions

func CreateNewRequestContext

func CreateNewRequestContext(c *gin.Context) context.Context

CreateNewRequestContext 创建新的请求上下文

func GetActionName

func GetActionName(ctx context.Context) string

GetActionName 从 context.Context 中获取 访问接口的名称

func GetTraceId

func GetTraceId(ctx context.Context) string

GetTraceId 从 context.Context 中获取 trace-id

func SchemeDetector

func SchemeDetector() gin.HandlerFunc

func SetActionName

func SetActionName(ctx context.Context, actionName string) context.Context

SetActionName 从 context.Context 中获取 访问接口的名称

func SetUserInfo

func SetUserInfo(ctx context.Context, uid int64, mobile, idCard string) context.Context

SetUserInfo 从 context.Context 中设置用户信息

func TraceMiddleware

func TraceMiddleware() gin.HandlerFunc

TraceMiddleware 注入 trace-id 到上下文及返回响应头

Types

type CtxUserInfo

type CtxUserInfo struct {
	Uid    string
	Mobile string
	IdCard string
}

func GetUserInfo

func GetUserInfo(ctx context.Context) CtxUserInfo

GetUserInfo 获取用户信息

Jump to

Keyboard shortcuts

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