Documentation
¶
Index ¶
- Constants
- type GinRouterBuilder
- type GoRestfulRouterBuilder
- type Http
- func (h *Http) Addr() string
- func (h *Http) ApiObjectAddr(obj ioc.Object) string
- func (h *Http) ApiObjectPathPrefix(obj ioc.Object) string
- func (h *Http) BuildRouter() error
- func (h *Http) DetectAndSetWebFramework()
- func (h *Http) GetRouterBuilder() RouterBuilder
- func (h *Http) HTTPPrefix() string
- func (h *Http) Init() error
- func (h *Http) Name() string
- func (h *Http) Start(ctx context.Context)
- func (h *Http) Stop(ctx context.Context) error
- func (a *Http) SwagerDocs(swo *spec.Swagger)
- type RouterBuilder
- type RouterBuilderHooks
- type RouterHook
- type WEB_FRAMEWORK
Constants ¶
View Source
const (
AppName = "http"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GinRouterBuilder ¶
type GinRouterBuilder struct {
*RouterBuilderHooks
}
func NewGinRouterBuilder ¶
func NewGinRouterBuilder() *GinRouterBuilder
type GoRestfulRouterBuilder ¶
type GoRestfulRouterBuilder struct {
*RouterBuilderHooks
}
func NewGoRestfulRouterBuilder ¶
func NewGoRestfulRouterBuilder() *GoRestfulRouterBuilder
type Http ¶
type Http struct {
ioc.ObjectImpl
// 是否开启HTTP Server, 默认会根据是否有注册得有API对象来自动开启
Enable *bool `json:"enable" yaml:"enable" toml:"enable" env:"HTTP_ENABLE"`
// HTTP服务Host
Host string `json:"host" yaml:"host" toml:"host" env:"HTTP_HOST"`
// HTTP服务端口
Port int `json:"port" yaml:"port" toml:"port" env:"HTTP_PORT"`
// API接口前缀
PathPrefix string `json:"path_prefix" yaml:"path_prefix" toml:"path_prefix" env:"HTTP_PATH_PREFIX"`
// 使用的http框架, 默认会根据当前注册的API对象,自动选择合适的框架
WEB_FRAMEWORK WEB_FRAMEWORK `json:"web_framework" yaml:"web_framework" toml:"web_framework" env:"HTTP_WEB_FRAMEWORK"`
// HTTP服务器参数
// HTTP Header读取超时时间
ReadHeaderTimeoutSecond int `json:"read_header_timeout" yaml:"read_header_timeout" toml:"read_header_timeout" env:"HTTP_READ_HEADER_TIMEOUT"`
// 读取HTTP整个请求时的参数
ReadTimeoutSecond int `json:"read_timeout" yaml:"read_timeout" toml:"read_timeout" env:"HTTP_READ_TIMEOUT"`
// 响应超时时间
WriteTimeoutSecond int `json:"write_timeout" yaml:"write_timeout" toml:"write_timeout" env:"HTTP_WRITE_TIMEOUT"`
// 启用了KeepAlive时 复用TCP链接的超时时间
IdleTimeoutSecond int `json:"idle_timeout" yaml:"idle_timeout" toml:"idle_timeout" env:"HTTP_IDLE_TIMEOUT"`
// header最大大小
MaxHeaderSize string `json:"max_header_size" yaml:"max_header_size" toml:"max_header_size" env:"HTTP_MAX_HEADER_SIZE"`
// 开启Trace
EnableTrace bool `toml:"enable_trace" json:"enable_trace" yaml:"enable_trace" env:"HTTP_ENABLE_TRACE"`
// 开启Trace
Debug bool `toml:"debug" json:"debug" yaml:"debug" env:"HTTP_DEBUG"`
// contains filtered or unexported fields
}
func (*Http) ApiObjectPathPrefix ¶ added in v2.0.6
func (*Http) BuildRouter ¶
func (*Http) DetectAndSetWebFramework ¶
func (h *Http) DetectAndSetWebFramework()
func (*Http) GetRouterBuilder ¶
func (h *Http) GetRouterBuilder() RouterBuilder
func (*Http) HTTPPrefix ¶
func (*Http) SwagerDocs ¶
type RouterBuilder ¶
type RouterBuilder interface {
BeforeLoadHooks(...RouterHook)
AfterLoadHooks(...RouterHook)
Build() (http.Handler, error)
}
type RouterBuilderHooks ¶ added in v2.0.6
type RouterBuilderHooks struct {
Before []RouterHook
After []RouterHook
}
func NewRouterBuilderHooks ¶ added in v2.0.6
func NewRouterBuilderHooks() *RouterBuilderHooks
func (*RouterBuilderHooks) AfterLoadHooks ¶ added in v2.0.6
func (b *RouterBuilderHooks) AfterLoadHooks(hooks ...RouterHook)
func (*RouterBuilderHooks) BeforeLoadHooks ¶ added in v2.0.6
func (b *RouterBuilderHooks) BeforeLoadHooks(hooks ...RouterHook)
type RouterHook ¶ added in v2.0.6
type WEB_FRAMEWORK ¶
type WEB_FRAMEWORK string
const ( // 根据ioc当前加载的对象自动判断使用那种框架 WEB_FRAMEWORK_AUTO WEB_FRAMEWORK = "" WEB_FRAMEWORK_GO_RESTFUL WEB_FRAMEWORK = "go-restful" WEB_FRAMEWORK_GIN WEB_FRAMEWORK = "gin" )
Click to show internal directories.
Click to hide internal directories.