Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectUserAgentLanguage ¶ added in v3.0.1
func DetectUserAgentLanguage() gin.HandlerFunc
DetectUserAgentLanguage 检测客户端语言
通过解析请求头中的`Accept-Language`字段得到
默认为`en`
func LogTrace ¶ added in v3.0.3
func LogTrace() gin.HandlerFunc
LogTrace 日志追踪
作用是在请求入口注入必要的内容到上下文,供后续的请求调用链使用,一般用于日志追踪、链路追踪
注入内容:
1.请求id
2.请求到来那一刻的纳秒时间戳
3.包装了请求id的日志组件实例
Example:
requestId, ok := ginContext.Get("requestId").(string)
spanId, ok := ginContext.Get("spanId").(string)
entryAt, ok := ginContext.Get("entryAt").(int64)
logger, ok := ginContext.Get("logger").(*zap.Logger)
func PrometheusExporter ¶
func PrometheusExporter() gin.HandlerFunc
PrometheusExporter 导出Prometheus指标
func WithCorsOnlyOptions ¶ added in v3.0.3
func WithCorsOnlyOptions(headers map[string]string) gin.HandlerFunc
WithCorsOnlyOptions 允许浏览器跨域请求
仅对options探测请求注入放行headers
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.