Documentation
¶
Index ¶
- Constants
- Variables
- func PromHandler(handler http.Handler) gin.HandlerFunc
- type BaseHttpService
- type GinEngine
- func (ge *GinEngine) Close()
- func (ge *GinEngine) GetRegisteredGroup(path string) (*gin.RouterGroup, error)
- func (ge *GinEngine) InitializeRoutes()
- func (ge *GinEngine) IsReleaseMode() bool
- func (ge *GinEngine) MiddlewareRegistry(middleware ...gin.HandlerFunc)
- func (ge *GinEngine) RouteGroupRegistry(path string, baseGroup *gin.RouterGroup)
- func (ge *GinEngine) RunAndService()
- func (ge *GinEngine) ServiceRegistry(services ...serviceInterface)
- type GinEngineConf
- type GinEngineFeatureOpts
- type GinEngineNoMatchHandlers
- type GinHttpProfService
- type HttpServerConf
- type PromOpts
Constants ¶
View Source
const ( ConstPromMetricUrlPath = "/metrics" ConstHttpHealthCheckUrlPath = "/health_check" ConstRootUrlPath = "/" ConstSwaggerUrlPath = "/docs/*any" )
Variables ¶
View Source
var RouteNoRegisteredError = errors.New("router group not registered")
Functions ¶
func PromHandler ¶
func PromHandler(handler http.Handler) gin.HandlerFunc
PromHandler wrappers the standard http.Handler to gin.HandlerFunc
Types ¶
type BaseHttpService ¶
type BaseHttpService struct {
// contains filtered or unexported fields
}
func NewBaseHttpService ¶
func NewBaseHttpService(f func(*gin.RouterGroup)) *BaseHttpService
func (*BaseHttpService) RoutesRegistry ¶
func (bhs *BaseHttpService) RoutesRegistry(ge *GinEngine)
type GinEngine ¶
type GinEngine struct {
RootRouteGroup *gin.RouterGroup
// contains filtered or unexported fields
}
func NewGinEngine ¶
func NewGinEngine(name string, engineConf *GinEngineConf, httpConf *HttpServerConf) *GinEngine
func (*GinEngine) GetRegisteredGroup ¶
func (ge *GinEngine) GetRegisteredGroup(path string) (*gin.RouterGroup, error)
GetRegisteredGroup 获得已经注册的路由组
func (*GinEngine) InitializeRoutes ¶
func (ge *GinEngine) InitializeRoutes()
func (*GinEngine) IsReleaseMode ¶
func (*GinEngine) MiddlewareRegistry ¶
func (ge *GinEngine) MiddlewareRegistry(middleware ...gin.HandlerFunc)
func (*GinEngine) RouteGroupRegistry ¶
func (ge *GinEngine) RouteGroupRegistry(path string, baseGroup *gin.RouterGroup)
RouteGroupRegistry 注册一个路由组
func (*GinEngine) RunAndService ¶
func (ge *GinEngine) RunAndService()
func (*GinEngine) ServiceRegistry ¶
func (ge *GinEngine) ServiceRegistry(services ...serviceInterface)
ServiceRegistry 注册服务到 GinEngine
type GinEngineConf ¶
type GinEngineConf struct {
FeatureOpts GinEngineFeatureOpts
NoMatchHandlers GinEngineNoMatchHandlers
}
func NewStrictRestApiGinEngineConf ¶
func NewStrictRestApiGinEngineConf() *GinEngineConf
func NewStrictRestApiReleaseModeGinEngineConf ¶
func NewStrictRestApiReleaseModeGinEngineConf() *GinEngineConf
type GinEngineFeatureOpts ¶
type GinEngineFeatureOpts struct {
EnableGinRedirectTrailingSlash bool // 内部 301 路径跳转,如果当前路径的处理函数不存在,但是路径+'/'的处理函数存在,则允许进行重定向
EnableGinRedirectFixedPath bool // 允许修复当前请求路径,如/FOO和/..//Foo会被修复为/foo,并进行重定向,默认为 false。
EnableHttpHealthCheck bool // 健康检查
EnablePrometheusMetrics bool // 记录 Prometheus 数据
EnablePrometheusRoute bool // 能够访问 Prometheus 数据
EnableSwagger bool // Swagger
EnableHttpPProf bool // running time debug
}
type GinEngineNoMatchHandlers ¶
type GinEngineNoMatchHandlers = struct {
NoRouteHandlers []gin.HandlerFunc
NoMethodHandlers []gin.HandlerFunc
}
type GinHttpProfService ¶
type GinHttpProfService struct {
}
func NewGinHttpProfService ¶
func NewGinHttpProfService() *GinHttpProfService
func (GinHttpProfService) RoutesRegistry ¶
func (gp GinHttpProfService) RoutesRegistry(ge *GinEngine)
type HttpServerConf ¶
type HttpServerConf struct {
Address string `json:"address" yaml:"address" mapstructure:"address"`
Port uint16 `json:"port" yaml:"port" mapstructure:"port"`
ReadTimeout uint32 `json:"read_timeout,omitempty" yaml:"read_timeout,omitempty" mapstructure:"read_timeout"`
WriteTimeout uint32 `json:"write_timeout,omitempty" yaml:"write_timeout,omitempty" mapstructure:"write_timeout"`
ReadHeaderTimeout uint32 `json:"read_header_timeout,omitempty" yaml:"read_header_timeout,omitempty" mapstructure:"read_header_timeout"`
DisableKeepalive bool `json:"disable_keepalive,omitempty" yaml:"disable_keepalive,omitempty" mapstructure:"disable_keepalive"`
}
type PromOpts ¶
type PromOpts struct {
ExcludeRegexAppName string
ExcludeRegexStatus string
ExcludeRegexUrlPath string
ExcludeRegexMethod string
ExcludeRegexClientIp string
UrlPathLabelMappingFn requestLabelMappingFn
}
PromOpts represents the Prometheus middleware Options. It is used for filtering labels by regex.
Click to show internal directories.
Click to hide internal directories.