public

package
v0.0.0-...-2828958 Latest Latest
Warning

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

Go to latest
Published: May 22, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CtxResponseKey = "response" // response
	CtxUserIDKey   = "userID"   // userID
	CtxUserKey     = "user"

	// 验证相关 Key
	CtxValidatorKey  = "ValidatorKey"
	CtxTranslatorKey = "TranslatorKey"

	// JWT
	JWTSignKey = "my_sign_key"
	JWTExpires = 60 * 60
)

需要设置的上下文相关的一些全局 Key

View Source
const (
	// Session Key 用于 session 认证
	KeySessionUser      = "user"
	KeyAdminSessionInfo = "AdminSessionInfoKey"
)

Context 之外的其他全局 Key

View Source
const (
	HeaderTraceID    = "com-header-rid"
	HeaderSpanID     = "com-header-spanid"
	ContextStartTime = "startExecTime"
	ContextTrace     = "trace"
)

requestlog 中使用

View Source
const (
	LoadTypeHTTP = 0
	LoadTypeTCP  = 1
	LoadTypeGRPC = 2

	HTTPRuleTypePrefixURL = 0
	HTTPRuleTypeDomain    = 1
)
View Source
const (
	// 流量统计的 Key
	RedisFlowDayKey  = "flow_day_count"
	RedisFlowHourKey = "flow_hour_count"

	// 流量前缀
	FlowTotal          = "flow_total"
	FlowServicePrefix  = "flow_service_"
	FlowCountAppPrefix = "flow_app_"
	FlowAppPrefix      = "flow_app_"
)

Variables

View Source
var ErrorUserNotLogin = errors.New("用户未登录")
View Source
var (
	LoadTypeMap = map[int]string{
		LoadTypeHTTP: "HTTP",
		LoadTypeTCP:  "TCP",
		LoadTypeGRPC: "GRPC",
	}
)

Functions

func DefaultGetValidParams

func DefaultGetValidParams(c *gin.Context, params interface{}) error

DefaultGetValidParams 获取

func GenSaltPassword

func GenSaltPassword(salt, password string) string

GenSaltPassword 获取加盐密码

func GetCurrentUserID

func GetCurrentUserID(c *gin.Context) (userID int64, err error)

GetCurrentUserID 获取当前登录用户的 ID

func GetGinTraceContext

func GetGinTraceContext(c *gin.Context) *mylog.TraceContext

GetGinTraceContext 从gin的Context中获取数据

func GetPageInfo

func GetPageInfo(c *gin.Context) (int, int)

GetPageInfo 设置分页

func GetTranslation

func GetTranslation(c *gin.Context) (ut.Translator, error)

GetTranslation 获取翻译器

func GetValidator

func GetValidator(c *gin.Context) (*validator.Validate, error)

GetValidator 获取验证器

func InStringSlice

func InStringSlice(slice []string, str string) bool

InStringSlice 判断字符串是否在string切片中

func JWTDeCode

func JWTDeCode(tokenString string) (*jwt.StandardClaims, error)

func JWTEncode

func JWTEncode(claims jwt.StandardClaims) (string, error)

func MD5

func MD5(s string) string

MD5 md5加密

func ObjectToJson

func ObjectToJson(s interface{}) string

func ProxyGetGinTraceContext

func ProxyGetGinTraceContext(c *gin.Context) *proxylog.TraceContext

ProxyGetGinTraceContext 从gin的Context中获取数据

Types

This section is empty.

Jump to

Keyboard shortcuts

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