reqctx

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2025 License: MIT Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPool

func GetPool[REQ ReqCtx]() sync.Pool

func GetToken added in v0.2.0

func GetToken[REQ ReqCtx](r REQ) string

Types

type Auth added in v0.2.3

type Auth struct {
	AuthInfoRaw string
	AuthID      string
	AuthInfo
}

type AuthInfo

type AuthInfo interface {
	IdStr() string
}

type AuthInterface added in v0.2.0

type AuthInterface interface {
	ParseToken(token string, secret []byte) error
}

type Context

type Context[REQ ReqCtx] struct {
	context2.Context
	ReqValue
	ReqCtx REQ
}

func FromContext added in v0.3.9

func FromContext[REQ ReqCtx](ctx context.Context) (*Context[REQ], bool)

func New added in v0.0.26

func New[REQ ReqCtx](req REQ) *Context[REQ]

func (*Context[REQ]) Device added in v0.2.0

func (c *Context[REQ]) Device() *DeviceInfo

func (*Context[REQ]) Method

func (c *Context[REQ]) Method() string

func (*Context[REQ]) SendHeader added in v0.2.0

func (c *Context[REQ]) SendHeader(md metadata.MD) error

func (*Context[REQ]) SetCookie added in v0.2.0

func (c *Context[REQ]) SetCookie(v string) error

func (*Context[REQ]) SetHeader added in v0.2.0

func (c *Context[REQ]) SetHeader(md metadata.MD) error

func (*Context[REQ]) SetTrailer added in v0.2.0

func (c *Context[REQ]) SetTrailer(md metadata.MD) error

func (*Context[REQ]) Wrapper

func (c *Context[REQ]) Wrapper() context.Context

type DeviceInfo

type DeviceInfo struct {
	//设备
	Device    string  `json:"device" gorm:"size:255"`
	OS        string  `json:"os" gorm:"size:255"`
	AppCode   string  `json:"appCode" gorm:"size:255"`
	AppVer    string  `json:"appVer" gorm:"size:255"`
	IP        string  `json:"ip" gorm:"size:255"`
	Lng       float64 `json:"lng" gorm:"type:numeric(10,6)"`
	Lat       float64 `json:"lat" gorm:"type:numeric(10,6)"`
	Area      string  `json:"area" gorm:"size:255"`
	UserAgent string  `json:"userAgent" gorm:"size:255"`
}

func Device

func Device(infoHeader, area, location, userAgent, ip string) *DeviceInfo

info: device,os,appCode,appVersion area:xxx location:1.23456,2.123456

type ReqCtx

type ReqCtx interface {
	RequestContext() context.Context
	RequestHeader() httpi.Header
	ResponseHeader() httpi.Header
}

type ReqValue

type ReqValue struct {
	Token string
	Auth

	grpc.ServerTransportStream
	Internal string
	RequestAt
	// contains filtered or unexported fields
}

type RequestAt added in v0.2.0

type RequestAt struct {
	Time      time.Time
	TimeStamp int64
	// contains filtered or unexported fields
}

func NewRequestAt added in v0.2.0

func NewRequestAt() RequestAt

func NewRequestAtFromTime added in v0.2.0

func NewRequestAtFromTime(t time.Time) RequestAt

func (*RequestAt) String added in v0.2.0

func (r *RequestAt) String() string

Jump to

Keyboard shortcuts

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