Documentation
¶
Index ¶
- Constants
- Variables
- type BaseHttpService
- type GinEngine
- func (ge *GinEngine) Close()
- func (ge *GinEngine) GetGrpcServer() *grpc.Server
- func (ge *GinEngine) GetHttpRegisteredGroup(path string) (*gin.RouterGroup, error)
- func (ge *GinEngine) GrpcServiceRegistry(services ...GrpcRegisteredServiceItem)
- func (ge *GinEngine) HttpMiddlewareRegistry(middleware ...gin.HandlerFunc)
- func (ge *GinEngine) HttpRouteGroupRegistry(path string, baseGroup *gin.RouterGroup)
- func (ge *GinEngine) HttpServiceRegistry(services ...httpServiceInterface)
- func (ge *GinEngine) IsReleaseMode() bool
- func (ge *GinEngine) RunAndService()
- type GinEngineConf
- type GinEngineFeatureOpts
- type GinEngineMiddlewareOpts
- type GinEngineNoMatchHandlers
- type GinHttpProfService
- type GrpcRegisteredServiceItem
- 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 ¶
This section is empty.
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, middlewareOpts *GinEngineMiddlewareOpts) *GinEngine
func (*GinEngine) GetGrpcServer ¶ added in v1.1.0
func (*GinEngine) GetHttpRegisteredGroup ¶ added in v1.1.0
func (ge *GinEngine) GetHttpRegisteredGroup(path string) (*gin.RouterGroup, error)
GetHttpRegisteredGroup 获得已经注册的路由组
func (*GinEngine) GrpcServiceRegistry ¶ added in v1.1.0
func (ge *GinEngine) GrpcServiceRegistry(services ...GrpcRegisteredServiceItem)
GrpcServiceRegistry 注册服务到 GinEngine
func (*GinEngine) HttpMiddlewareRegistry ¶ added in v1.1.0
func (ge *GinEngine) HttpMiddlewareRegistry(middleware ...gin.HandlerFunc)
func (*GinEngine) HttpRouteGroupRegistry ¶ added in v1.1.0
func (ge *GinEngine) HttpRouteGroupRegistry(path string, baseGroup *gin.RouterGroup)
HttpRouteGroupRegistry 注册一个路由组
func (*GinEngine) HttpServiceRegistry ¶ added in v1.1.0
func (ge *GinEngine) HttpServiceRegistry(services ...httpServiceInterface)
HttpServiceRegistry 注册服务到 GinEngine
func (*GinEngine) IsReleaseMode ¶
func (*GinEngine) RunAndService ¶
func (ge *GinEngine) RunAndService()
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
EnableGrpc bool // 启动 grpc over http
}
type GinEngineMiddlewareOpts ¶ added in v1.1.0
type GinEngineMiddlewareOpts struct {
// contains filtered or unexported fields
}
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 GrpcRegisteredServiceItem ¶ added in v1.1.0
type GrpcRegisteredServiceItem struct {
ServiceDesc *grpc.ServiceDesc
ServiceServer interface{}
}
type HttpServerConf ¶
type HttpServerConf struct {
Address string `json:"address" yaml:"address"`
Port uint16 `json:"port" yaml:"port"`
ReadTimeout uint32 `json:"read_timeout,omitempty" yaml:"read_timeout,omitempty"`
WriteTimeout uint32 `json:"write_timeout,omitempty" yaml:"write_timeout,omitempty"`
ReadHeaderTimeout uint32 `json:"read_header_timeout,omitempty" yaml:"read_header_timeout,omitempty"`
DisableKeepalive bool `json:"disable_keepalive,omitempty" yaml:"disable_keepalive,omitempty"`
}
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.