Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultGetValidParams(c *gin.Context, params interface{}) error
- func GenSaltPassword(salt, password string) string
- func GetCurrentUserID(c *gin.Context) (userID int64, err error)
- func GetGinTraceContext(c *gin.Context) *mylog.TraceContext
- func GetPageInfo(c *gin.Context) (int, int)
- func GetTranslation(c *gin.Context) (ut.Translator, error)
- func GetValidator(c *gin.Context) (*validator.Validate, error)
- func InStringSlice(slice []string, str string) bool
- func JWTDeCode(tokenString string) (*jwt.StandardClaims, error)
- func JWTEncode(claims jwt.StandardClaims) (string, error)
- func MD5(s string) string
- func ObjectToJson(s interface{}) string
- func ProxyGetGinTraceContext(c *gin.Context) *proxylog.TraceContext
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 ¶
DefaultGetValidParams 获取
func GetCurrentUserID ¶
GetCurrentUserID 获取当前登录用户的 ID
func GetGinTraceContext ¶
func GetGinTraceContext(c *gin.Context) *mylog.TraceContext
GetGinTraceContext 从gin的Context中获取数据
func GetTranslation ¶
func GetTranslation(c *gin.Context) (ut.Translator, error)
GetTranslation 获取翻译器
func GetValidator ¶
GetValidator 获取验证器
func InStringSlice ¶
InStringSlice 判断字符串是否在string切片中
func ObjectToJson ¶
func ObjectToJson(s interface{}) string
func ProxyGetGinTraceContext ¶
func ProxyGetGinTraceContext(c *gin.Context) *proxylog.TraceContext
ProxyGetGinTraceContext 从gin的Context中获取数据
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.