Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultGetValidParams(c *gin.Context, params interface{}) error
- func GenSaltPassword(salt, password string) string
- func GetGinTraceContext(c *gin.Context) *trace.Trace
- func GetTranslation(c *gin.Context) (ut.Translator, error)
- func GetValidator(c *gin.Context) (*validator.Validate, error)
- func GinLogNotice(c *gin.Context, dltag string, m map[string]interface{})
- func GinLogWarning(c *gin.Context, dltag string, m map[string]interface{})
- func HTTPPathsValidate(httpPaths string) error
- func InArrayString(s string, arr []string) bool
- func InIPSliceStr(targetIP, ipSliceStr string) bool
- func JwtDecode(tokenString string) (*jwt.StandardClaims, error)
- func JwtEncode(claims jwt.StandardClaims) (string, error)
- func MD5(s string) string
- func Obj2Json(s interface{}) string
- func RedisConfDo(commandName string, args ...interface{}) (interface{}, error)
- func RedisConfPipline(pip ...func(c redis.Conn)) error
- func ResponseError(c *gin.Context, code ResponseCode, err error)
- func ResponseSuccess(c *gin.Context, data interface{})
- func ServiceNameValidate(serviceName string) error
- func UpstreamListValidate(upstreamList string) error
- type Response
- type ResponseCode
Constants ¶
View Source
const ( ValidatorKey = "ValidatorKey" TranslatorKey = "TranslatorKey" AdminSessionInfoKey = "AdminSessionInfoKey" LoadTypeHTTP = 0 LoadTypeTCP = 1 LoadTypeGRPC = 2 HTTPRuleTypePrefixURL = 0 HTTPRuleTypeDomain = 1 //flow_counter_store RedisFlowDayKey = "flow_day_count" RedisFlowHourKey = "flow_hour_count" //flow_limit && http_flow_limit function app&server's name or prefix FlowTotal = "flow_total" FlowServicePrefix = "flow_service_" FlowAppPrefix = "flow_app_" //distributed limter prefix DistributedLimiterPrefix = "dist_limiter_" JwtSignKey = "my_sign_key" JwtExpires = 60 * 60 //middleware context key ServiceDetailContextKey = "service" )
Variables ¶
View Source
var ( LoadTypeMap = map[int]string{ LoadTypeHTTP: "HTTP", LoadTypeTCP: "TCP", LoadTypeGRPC: "GRPC", } )
Functions ¶
func DefaultGetValidParams ¶ added in v1.0.0
func GenSaltPassword ¶ added in v1.0.0
func GetTranslation ¶ added in v1.0.0
func GetTranslation(c *gin.Context) (ut.Translator, error)
func GetValidator ¶ added in v1.0.0
func GinLogNotice ¶ added in v1.0.0
func GinLogWarning ¶ added in v1.0.0
func HTTPPathsValidate ¶ added in v1.0.0
func InArrayString ¶ added in v1.0.0
func InIPSliceStr ¶ added in v1.0.0
func RedisConfDo ¶
func RedisConfPipline ¶
func ResponseError ¶
func ResponseError(c *gin.Context, code ResponseCode, err error)
func ResponseSuccess ¶
func ServiceNameValidate ¶ added in v1.0.0
func UpstreamListValidate ¶ added in v1.0.0
Types ¶
type Response ¶
type Response struct { ErrorCode ResponseCode `json:"errno"` ErrorMsg string `json:"errmsg"` Data interface{} `json:"data"` TraceId interface{} `json:"trace_id"` Stack interface{} `json:"stack"` }
type ResponseCode ¶
type ResponseCode int
const ( SuccessCode ResponseCode = iota UndefErrorCode ValidErrorCode InternalErrorCode InvalidRequestErrorCode ResponseCode = 401 CustomizeCode ResponseCode = 1000 GROUPALL_SAVE_FLOWERROR ResponseCode = 2001 )
1000以下为通用码,1000以上为用户自定义码
Source Files ¶
Click to show internal directories.
Click to hide internal directories.