ctxkit

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package ctxkit 操作请求 ctx 信息

Index

Constants

View Source
const (
	// TraceIDKey 请求唯一标识,类型:string
	TraceIDKey key = iota
	// StartTimeKey 请求开始时间,类型:time.Time
	StartTimeKey
	// UserTokenKey 用户登陆身份,未登录则为 "",类型:string
	UserTokenKey
	// UserIDKey 用户 ID,未登录则为 0,类型:int64
	UserIDKey
	// UserIPKey 用户 IP,类型:string
	UserIPKey
	// PlatformKey 用户使用平台,ios, android, pc
	PlatformKey
	// ProjectKey
	ProjectKey
	// ProjectDBKey
	ProjectDBNameKey
	// BuildKey 客户端构建版本号
	BuildKey
	// VersionKey 客户端版本号
	VersionKey
	// AccessKeyKey 移动端支付令牌
	AccessKeyKey
	// DeviceKey 移动 app 设备标识,android, phone, pad
	DeviceKey
	// MobiAppKey 移动 app 标识,android, phone, pad
	MobiAppKey
	// UserPortKey 用户端口
	UserPortKey
	// ManageUserKey 管理后台用户名
	ManageUserKey
	// BuvidKey 非登录用户标识
	BuvidKey
	// CookieKey web 用户登录令牌
	CookieKey
	// CompanyAppKeyKey
	CompanyAppKeyKey
	// AppKeyKey 接口签名标识
	AppKeyKey
	// TsKey 时间戳
	TSKey
	// SignKey 签名
	SignKey
	// IsValidSignKeyKey 签名正确则置为 true
	IsValidSignKeyKey
	// http 请求对象
	HttpRawReqKey
	// http 请求响应对象
	HttpRawRespKey
	// User-Agent
	UserAgentKey
	// HttpRefer
	HttpReferKey
	// WxSessionKey
	WxSessionKey
	// WxOpenIdKey
	WxOpenIdKey
	// WxPhoneBindKey
	WxPhoneBindKey
	// MpPlatformIdKey
	MpPlatformIdKey
	// WXAPPIdKey
	WXAPPIdKey
	// QQAPPIdKey
	QQAPPIdKey
)

Variables

This section is empty.

Functions

func GetAccessKey

func GetAccessKey(ctx context.Context) string

GetAccessKey 获取客户端认证令牌

func GetBuild

func GetBuild(ctx context.Context) string

GetBuild 获取客户端构建版本号

func GetBuvid

func GetBuvid(ctx context.Context) string

GetBuvid 获取用户 buvid

func GetCompanyAppKey

func GetCompanyAppKey(ctx context.Context) string

GetPlatform 获取用户平台

func GetCookie

func GetCookie(ctx context.Context) string

GetCookie 获取 web cookie

func GetDevice

func GetDevice(ctx context.Context) string

GetDevice 获取用户设备,配合 GetPlatform 使用

func GetHttpRefer

func GetHttpRefer(ctx context.Context) string

GetUserAgent 获取用户 refer

func GetHttpReq

func GetHttpReq(ctx context.Context) *http.Request

GetHttpReq 获取 web cookie

func GetHttpResp

func GetHttpResp(ctx context.Context) http.ResponseWriter

GetCookie 获取 web cookie

func GetManageUser

func GetManageUser(ctx context.Context) string

GetManageUser 获取管理后台用户名

func GetMobiApp

func GetMobiApp(ctx context.Context) string

GetMobiApp 获取 APP 标识

func GetPlatform

func GetPlatform(ctx context.Context) string

GetPlatform 获取用户平台

func GetProject

func GetProject(ctx context.Context) string

GetProject 获取配置项目

func GetProjectDBName

func GetProjectDBName(ctx context.Context) string

GetProjectDBName 获取配置项目

func GetQQAppId

func GetQQAppId(ctx context.Context) string

func GetSign

func GetSign(ctx context.Context) (appkey, ts, sign string)

func GetTokenPlatformId

func GetTokenPlatformId(ctx context.Context) int32

GetUserToken 获取用户 token

func GetTraceID

func GetTraceID(ctx context.Context) string

GetTraceID 获取用户请求标识

func GetUserAgent

func GetUserAgent(ctx context.Context) string

GetUserAgent 获取用户 ua

func GetUserID

func GetUserID(ctx context.Context) int64

GetUserID 获取当前登录用户 ID

func GetUserIP

func GetUserIP(ctx context.Context) string

GetUserIP 获取用户 IP

func GetUserPort

func GetUserPort(ctx context.Context) string

GetUserPort 获取用户端口

func GetUserToken

func GetUserToken(ctx context.Context) string

GetUserToken 获取用户 token

func GetVersion

func GetVersion(ctx context.Context) string

GetVersion 获取客户端版本

func GetWXAppId

func GetWXAppId(ctx context.Context) string

func GetWxOpenId

func GetWxOpenId(ctx context.Context) string

GetWxSession 获取用户 session key

func GetWxSessionKey

func GetWxSessionKey(ctx context.Context) string

GetWxSession 获取用户 session key

func IsIOSPlatform

func IsIOSPlatform(ctx context.Context) bool

IsIOSPlatform 判断是否为 IOS 平台

func IsValidSignKey

func IsValidSignKey(ctx context.Context) bool

IsValidSignKey 判断业务签名是否正确

func IsWxPhoneBind

func IsWxPhoneBind(ctx context.Context) bool

GetWxSession 获取用户 session key

func WithDevice

func WithDevice(ctx context.Context, device string) context.Context

func WithHttpRefer

func WithHttpRefer(ctx context.Context, refer string) context.Context

func WithHttpReq

func WithHttpReq(ctx context.Context, req *http.Request) context.Context

WithHttpReq 注入 HttpRawReqKey

func WithHttpResp

func WithHttpResp(ctx context.Context, resp http.ResponseWriter) context.Context

WithHttpResp 注入 TraceIDKey

func WithMPPlatformId

func WithMPPlatformId(ctx context.Context, pid int32) context.Context

func WithMobiApp

func WithMobiApp(ctx context.Context, os string) context.Context

func WithPlatform

func WithPlatform(ctx context.Context, platform string) context.Context

func WithProject

func WithProject(ctx context.Context, project string) context.Context

func WithProjectDBNameKey

func WithProjectDBNameKey(ctx context.Context, name string) context.Context

func WithQQAppId

func WithQQAppId(ctx context.Context, appid string) context.Context

func WithTraceID

func WithTraceID(ctx context.Context, traceID string) context.Context

WithTraceID 注入 trace_id

func WithUserAgent

func WithUserAgent(ctx context.Context, ua string) context.Context

func WithUserID

func WithUserID(ctx context.Context, uid int64) context.Context

func WithUserIP

func WithUserIP(ctx context.Context, ip string) context.Context

func WithUserToken

func WithUserToken(ctx context.Context, token string) context.Context

func WithVersion

func WithVersion(ctx context.Context, version string) context.Context

func WithWXAppId

func WithWXAppId(ctx context.Context, appid string) context.Context

func WithWxOpenId

func WithWxOpenId(ctx context.Context, openid string) context.Context

func WithWxPhoneBind

func WithWxPhoneBind(ctx context.Context, bind int) context.Context

func WithWxSessionKey

func WithWxSessionKey(ctx context.Context, sessionKey string) context.Context

Types

This section is empty.

Jump to

Keyboard shortcuts

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