content

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContext

func NewContext(ctx context.Context, rc *RequestContext) context.Context

NewContext 创建新的上下文

Types

type RequestContext

type RequestContext struct {
	GinContext   *gin.Context    // gin上下文
	RequestQuery *datatypes.JSON `json:"request_query"`
	RequestBody  *datatypes.JSON `json:"request_body"`
	// 添加一个通用的map用于存储自定义数据
	CustomData map[string]any `json:"custom_data"`
}

func FromContext

func FromContext(ctx context.Context) *RequestContext

FromContext 从标准 context 获取

func FromGin

func FromGin(c *gin.Context) *RequestContext

FromGin 直接从 gin.Context 获取自定义上下文

func (*RequestContext) Get added in v1.0.9

func (rc *RequestContext) Get(key string) (any, bool)

Get 获取自定义数据

func (*RequestContext) GetInt added in v1.0.9

func (rc *RequestContext) GetInt(key string) (int, bool)

GetInt 获取整数类型的值

func (*RequestContext) GetString added in v1.0.9

func (rc *RequestContext) GetString(key string) (string, bool)

GetString 获取字符串类型的值

func (*RequestContext) Set added in v1.0.9

func (rc *RequestContext) Set(key string, value any)

Set 设置自定义数据

Jump to

Keyboard shortcuts

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