Documentation
¶
Index ¶
- Constants
- Variables
- func Auth(c *gin.Context)
- func AuthJson(c *gin.Context)
- func Error(c *gin.Context, codeErr *code_err.CodeErr, err error)
- func GetCurrentGoroutineStack(err interface{}) []byte
- func GetDuration(ctx context.Context) time.Duration
- func GetDurationMilliseconds(ctx context.Context) float64
- func GetStartTime(ctx context.Context) time.Time
- func HeaderCarrierInterceptor() gin.HandlerFunc
- func HmacSHA256Sign(secret []byte, params []byte) (string, error)
- func Log(ctx context.Context, cfg *http_server_config.Config) gin.HandlerFunc
- func LogJson(c *gin.Context, cfg *http_server_config.Config)
- func Md5(s string) string
- func MetricInterceptor(cfg *http_server_config.Config) gin.HandlerFunc
- func SetStartTimeInterceptor() gin.HandlerFunc
- func Sha256(text []byte) []byte
- func Sha256ToHex(text []byte) string
- func Sign(validateToken func(token string) (uid string, err error)) gin.HandlerFunc
- func Timeout(timeout time.Duration) func(c *gin.Context)
- func Token(c *gin.Context)
- func Trace(ctx context.Context) gin.HandlerFunc
- func ValidateSign(signParam string, appKey string, bodyParams []byte) (err error)
- type BodyLogWriter
- type LogData
Constants ¶
View Source
const ( UidHeader = "X-Uid" DebugHeader = "X-Debug" TokenHeader = "X-Token" NonceHeader = "X-Nonce" TimestampHeader = "X-Timestamp" SignHeader = "X-Sign" LanguageHeader = "X-Language" TokenPrefix = "token#" UserPrefix = "user#" CodeExpiryTime = 15 * 60 //15分钟 TokenExpiryTime = 7 * 86400 * time.Second //7天 )
Variables ¶
View Source
var ( // ServerHandleCounter ... ServerHandleCounter = prometheus.NewCounterVec( prometheus.CounterOpts{ Namespace: "", Name: "http_server_handle_total", }, []string{"name", "method", "path", "host", "code"}) // ServerHandleHistogram ... ServerHandleHistogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{ Namespace: "", Name: "http_server_handle_seconds", }, []string{"name", "method", "path", "host"}) )
Functions ¶
func GetCurrentGoroutineStack ¶
func GetCurrentGoroutineStack(err interface{}) []byte
GetCurrentGoroutineStack 获取当前Goroutine的调用栈,便于排查panic异常
func GetDurationMilliseconds ¶
func Log ¶
func Log(ctx context.Context, cfg *http_server_config.Config) gin.HandlerFunc
Log returns a middleware and handles the control to the centralized HTTPErrorHandler.
func MetricInterceptor ¶
func MetricInterceptor(cfg *http_server_config.Config) gin.HandlerFunc
func SetStartTimeInterceptor ¶
func SetStartTimeInterceptor() gin.HandlerFunc
func Sha256ToHex ¶
func Sign ¶
func Sign(validateToken func(token string) (uid string, err error)) gin.HandlerFunc
Sign
Types ¶
type BodyLogWriter ¶
type BodyLogWriter struct { gin.ResponseWriter // contains filtered or unexported fields }
func (BodyLogWriter) WriteString ¶
func (w BodyLogWriter) WriteString(s string) (int, error)
Click to show internal directories.
Click to hide internal directories.