Documentation
¶
Overview ¶
Package ginqq 自定义的context,用于传递系统上下文信息,如服务编码,traceId等
Index ¶
- Constants
- func ApiStandardServerMiddleware() func(*Context)
- func GenerateUuid() string
- func HttpEnhance(cfg *HttpClientEnhanceConfig)
- func LoggingServerMiddleware() func(*Context)
- func MetricsServerMiddleware() func(*Context)
- func SecurityMiddleware() func(*Context)
- func TracingServerMiddleware() func(*Context)
- type ChainBuilder
- type Config
- type Context
- type GinQQ
- func (g *GinQQ) DELETE(relativePath string, handlers ...func(*Context))
- func (g *GinQQ) GET(relativePath string, handlers ...func(*Context))
- func (g *GinQQ) Group(relativePath string, handlers ...func(*Context)) *RouterGroup
- func (g *GinQQ) POST(relativePath string, handlers ...func(*Context))
- func (g *GinQQ) PUT(relativePath string, handlers ...func(*Context))
- func (g *GinQQ) Use(handlers ...func(*Context))
- type H
- type HttpClientEnhanceConfig
- type LoggingTripper
- type LoggingTripper2
- type MetricsConfig
- type RouterGroup
- func (g *RouterGroup) DELETE(relativePath string, handlers ...func(*Context))
- func (g *RouterGroup) GET(relativePath string, handlers ...func(*Context))
- func (g *RouterGroup) POST(relativePath string, handlers ...func(*Context))
- func (g *RouterGroup) PUT(relativePath string, handlers ...func(*Context))
Constants ¶
View Source
const ( CtxKeyMethodCode = "Method-Code" CtxKeyTraceID = "Trace-ID" )
Variables ¶
This section is empty.
Functions ¶
func ApiStandardServerMiddleware ¶
func ApiStandardServerMiddleware() func(*Context)
func GenerateUuid ¶
func GenerateUuid() string
func HttpEnhance ¶
func HttpEnhance(cfg *HttpClientEnhanceConfig)
func LoggingServerMiddleware ¶
func LoggingServerMiddleware() func(*Context)
LoggingServerMiddleware 系统日志中间件
func MetricsServerMiddleware ¶
func MetricsServerMiddleware() func(*Context)
func SecurityMiddleware ¶
func SecurityMiddleware() func(*Context)
func TracingServerMiddleware ¶
func TracingServerMiddleware() func(*Context)
Types ¶
type ChainBuilder ¶
type ChainBuilder struct {
// contains filtered or unexported fields
}
ChainBuilder 链式构建器,用于构建中间件链,
func NewChainBuilder ¶
func NewChainBuilder(base http.RoundTripper) *ChainBuilder
func (*ChainBuilder) Use ¶
func (b *ChainBuilder) Use(middlewares ...http.RoundTripper) *ChainBuilder
Use 构建中间件链表,头插法
type Config ¶
type Config struct {
// 基础信息,必传字段
ServiceCode string // 服务编码
PlatCode string // 平台编码
// 功能开关&配置
// 服务端系统可观测性
DisableMetrics bool
MetricsConfig *MetricsConfig
DisableTracing bool // 链路
DisableLoggingServer bool // 内部流水
// 服务端API规范化
DisableApiStandardServer bool // 服务端API规范调用&校验拦截
// Http客户端配置
DisableHttpClientEnhance bool // http增强
HttpClientEnhanceConfig *HttpClientEnhanceConfig
}
type Context ¶
func (*Context) GetMethodCode ¶
func (*Context) GetTraceId ¶
func (*Context) SetMethodCode ¶
SetMethodCode 框架中间件数据传递
type GinQQ ¶
GinQQ 自定义框架结构体
func NewEngineWithConfig ¶
type HttpClientEnhanceConfig ¶
type HttpClientEnhanceConfig struct {
Transport http.RoundTripper // 基础transport,默认使用http.DefaultTransport,可自定义transport设置连接池参数、超时时间等
DisableSkipVerify bool // 跳过证书认证,默认跳过 TODO 后续增加证书认证体系
DisableApiStandardClient bool // 客户端API规范调用&校验拦截
DisableLoggingClient bool // 外部流水
}
type LoggingTripper ¶
type LoggingTripper struct {
// contains filtered or unexported fields
}
func NewLoggingTripper ¶
func NewLoggingTripper() *LoggingTripper
func (*LoggingTripper) SetNext ¶
func (l *LoggingTripper) SetNext(next http.RoundTripper)
type LoggingTripper2 ¶
type LoggingTripper2 struct {
// contains filtered or unexported fields
}
LoggingTripper2 中间件示例,需要实现RoundTrip处理接口,SetNext设置下个中间接口
func NewLoggingTripper2 ¶
func NewLoggingTripper2() *LoggingTripper2
func (*LoggingTripper2) SetNext ¶
func (l *LoggingTripper2) SetNext(next http.RoundTripper)
type MetricsConfig ¶
type RouterGroup ¶
type RouterGroup struct {
*gin.RouterGroup
}
RouterGroup 自定义路由组,强制处理函数接收自定义的*Context
func (*RouterGroup) DELETE ¶
func (g *RouterGroup) DELETE(relativePath string, handlers ...func(*Context))
func (*RouterGroup) GET ¶
func (g *RouterGroup) GET(relativePath string, handlers ...func(*Context))
func (*RouterGroup) POST ¶
func (g *RouterGroup) POST(relativePath string, handlers ...func(*Context))
func (*RouterGroup) PUT ¶
func (g *RouterGroup) PUT(relativePath string, handlers ...func(*Context))
Source Files
¶
Click to show internal directories.
Click to hide internal directories.