reqctx

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: MIT, Apache-2.0, MIT Imports: 9 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetToken

func GetToken[REQ ReqCtx](r REQ) string

Types

type Auth

type Auth struct {
	AuthRaw string
	AuthID  string
	AuthInfo
}

type AuthInfo

type AuthInfo interface {
	GetId() string
}

type Context

type Context[REQ ReqCtx] struct {
	*contextx.Context
	Metadata
	ReqCtx REQ
}

func FromContext

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

func New

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

func (*Context[REQ]) Device

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

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"`
}

DeviceInfo device info

func Device

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

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

type Metadata added in v1.6.8

type Metadata struct {
	RequestTime
	Token string
	Auth

	Internal string
	// contains filtered or unexported fields
}

type ParseToken added in v1.6.8

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

type ReqCtx

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

type RequestTime added in v1.6.8

type RequestTime struct {
	Time       time.Time
	TimeStamp  int64
	TimeString string
}

func NewRequestAt

func NewRequestAt() RequestTime

func NewRequestAtFromTime

func NewRequestAtFromTime(t time.Time) RequestTime

func (*RequestTime) String added in v1.6.8

func (r *RequestTime) String() string

Jump to

Keyboard shortcuts

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