Documentation ¶
Index ¶
- Variables
- func GenerateRequestBody(c *gin.Context) string
- func GenerateRequestPath(c *gin.Context) string
- func GenerateResponseBody(c *gin.Context) string
- func ParseRequestBody(c *gin.Context, value interface{}, emptyRequestBodyContent bool) error
- type Engine
- type FeatureOpts
- type HttpServerConf
- type HttpService
Constants ¶
This section is empty.
Variables ¶
View Source
var DetermineRequestContentTypeError = errors.New("failed to determine the request content type. set http header with Content-Type")
View Source
var RouteNoRegisteredError = errors.New("router group not registered")
Functions ¶
func GenerateRequestBody ¶
GenerateRequestBody 从Gin的上下文中读取HTTP请求的Body,并将其存储到一个Buffer Pool对象中。
func GenerateRequestPath ¶
func GenerateResponseBody ¶
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func NewEngine ¶
func NewEngine(httpConf *HttpServerConf, featureOpts *FeatureOpts, middlewares *[]gin.HandlerFunc) *Engine
func (*Engine) GetHttpRegisteredGroup ¶
func (e *Engine) GetHttpRegisteredGroup(path string) (*gin.RouterGroup, error)
GetHttpRegisteredGroup 获得已经注册的路由组
func (*Engine) HttpRouteGroupRegistry ¶
func (e *Engine) HttpRouteGroupRegistry(path string, baseRouteGroup *gin.RouterGroup)
HttpRouteGroupRegistry 注册一个路由组
func (*Engine) HttpServiceRegistry ¶
func (e *Engine) HttpServiceRegistry(services ...httpServiceInterface)
HttpServiceRegistry 注册服务到 Engine
type FeatureOpts ¶
type FeatureOpts struct { EnableGinRedirectTrailingSlash bool `json:"enableGinRedirectTrailingSlash,omitempty" yaml:"enableGinRedirectTrailingSlash,omitempty"` // 内部 301 路径跳转,如果当前路径的处理函数不存在,但是路径+'/'的处理函数存在,则允许进行重定向 EnableGinRedirectFixedPath bool `json:"enableGinRedirectFixedPath,omitempty" yaml:"enableGinRedirectFixedPath,omitempty"` // 允许修复当前请求路径,如/FOO和/..//Foo会被修复为/foo,并进行重定向,默认为 false。 EnableGinForwardedByClientIP bool `json:"enableGinForwardedByClientIP,omitempty" yaml:"enableGinForwardedByClientIP,omitempty"` // 如果应用程序不在代理之后,“ForwardedByClientIP”应设置为 false,因此“X-Forwarded-For”将被忽略。 如果在代理后面将其设置为true。 EnableRecordContextBody bool `json:"EnableRecordContextBody,omitempty" yaml:"EnableRecordContextBody,omitempty"` // 记录会话 body 内容 EnableHttpHealthCheck bool `json:"enableHttpHealthCheck,omitempty" yaml:"enableHttpHealthCheck,omitempty"` // 健康检查 EnableMetrics bool `json:"enableMetrics,omitempty" yaml:"enableMetrics,omitempty"` // 记录 Prometheus 数据 EnableSwagger bool `json:"enableSwagger,omitempty" yaml:"enableSwagger,omitempty"` // Swagger EnableHttpPProf bool `json:"enableHttpPProf,omitempty" yaml:"enableHttpPProf,omitempty"` // running time debug }
func NewDefaultFeatureOpts ¶
func NewDefaultFeatureOpts() *FeatureOpts
type HttpServerConf ¶
type HttpServerConf struct { Address string `json:"address" yaml:"address"` Port uint16 `json:"port" yaml:"port"` HttpReadTimeout uint32 `json:"httpReadTimeout,omitempty" yaml:"httpReadTimeout,omitempty"` HttpWriteTimeout uint32 `json:"httpWriteTimeout,omitempty" yaml:"httpWriteTimeout,omitempty"` HttpReadHeaderTimeout uint32 `json:"httpReadHeaderTimeout,omitempty" yaml:"httpReadHeaderTimeout,omitempty"` Logger *zap.SugaredLogger `json:"-" yaml:"-"` }
func NewDefaultHttpServerConfig ¶
func NewDefaultHttpServerConfig() *HttpServerConf
type HttpService ¶
type HttpService struct {
// contains filtered or unexported fields
}
func NewHttpService ¶
func NewHttpService(f func(*gin.RouterGroup)) *HttpService
func (*HttpService) RoutesRegistry ¶
func (s *HttpService) RoutesRegistry(e *Engine)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.