contextx

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTraceId

func GetTraceId(ctx context.Context) string

GetTraceId 从context中获取traceId

func GetTraceUserId

func GetTraceUserId(ctx context.Context) any

GetTraceUserId 从context中解析traceUser的id

func GetTraceUserRole

func GetTraceUserRole(ctx context.Context) string

GetTraceUserRole 从context中解析traceUser的角色

func UnmarshalTraceUser

func UnmarshalTraceUser(ctx context.Context, ptr any) error

UnmarshalTraceUser 从context中解析出traceUser

func WithTraceId

func WithTraceId(parent context.Context) context.Context

WithTraceId 向context中注入traceId

func WithTraceUser

func WithTraceUser(parent context.Context, ustring string) context.Context

WithTraceUser 向context中注入traceUser

Types

type CtxKeyType

type CtxKeyType int
const (
	TraceIdKey CtxKeyType = iota
	TraceUserKey
)

type TraceUser

type TraceUser struct {
	UID  any    `json:"uid,omitempty"`
	Role string `json:"role,omitempty"`
}

Jump to

Keyboard shortcuts

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