Documentation
¶
Index ¶
- Constants
- Variables
- func Debug(arg ...interface{})
- func Debugf(format string, arg ...interface{})
- func DefaultGetValidParams(c *gin.Context, params interface{}) error
- func Error(arg ...interface{})
- func Errorf(format string, arg ...interface{})
- func GetLocalIPs() (ips []net.IP)
- func GetTraceId() (traceId string)
- func GetTranslation(c *gin.Context) (ut.Translator, error)
- func GetValidator(c *gin.Context) (*validator.Validate, error)
- func Info(arg ...interface{})
- func Infof(format string, arg ...interface{})
- func NewSpanId() string
- func ResponseError(c *gin.Context, code ResponseCode, err error)
- func ResponseSuccess(c *gin.Context, data interface{})
- func SetGinTraceContext(c *gin.Context, trace *TraceContext) error
- func SetTraceContext(ctx context.Context, trace *TraceContext) context.Context
- func Warn(arg ...interface{})
- func Warnf(format string, arg ...interface{})
- type Response
- type ResponseCode
- type Trace
- type TraceContext
Constants ¶
View Source
const ( ValidatorKey = "ValidatorKey" TranslatorKey = "TranslatorKey" AdminSessionInfoKey = "AdminSessionInfoKey" LoadTypeHTTP = 0 LoadTypeTCP = 1 LoadTypeGRPC = 2 HTTPRuleTypePrefixURL = 0 HTTPRuleTypeDomain = 1 RedisFlowDayKey = "flow_day_count" RedisFlowHourKey = "flow_hour_count" FlowTotal = "flow_total" FlowServicePrefix = "flow_service_" FlowAppPrefix = "flow_app_" JwtSignKey = "my_sign_key" JwtExpires = 60 * 60 )
Variables ¶
View Source
var ( LoadTypeMap = map[int]string{ LoadTypeHTTP: "HTTP", LoadTypeTCP: "TCP", LoadTypeGRPC: "GRPC", } )
Functions ¶
func DefaultGetValidParams ¶
func GetTraceId ¶
func GetTraceId() (traceId string)
func GetTranslation ¶
func GetValidator ¶
func ResponseError ¶
func ResponseError(c *gin.Context, code ResponseCode, err error)
func ResponseSuccess ¶
func SetGinTraceContext ¶
func SetGinTraceContext(c *gin.Context, trace *TraceContext) error
func SetTraceContext ¶
func SetTraceContext(ctx context.Context, trace *TraceContext) context.Context
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以上为用户自定义码
type TraceContext ¶
func GetGinTraceContext ¶
func GetGinTraceContext(c *gin.Context) *TraceContext
func GetTraceContext ¶
func GetTraceContext(ctx context.Context) *TraceContext
func NewTrace ¶
func NewTrace() *TraceContext
Click to show internal directories.
Click to hide internal directories.