Documentation
¶
Index ¶
- Constants
- type ApiDoc
- type BuildConfig
- type BuildHook
- type CORS
- type GinRouterBuilder
- type GoRestfulRouterBuilder
- type HealthCheck
- type Http
- func (h *Http) Addr() 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 WEB_FRAMEWORK
Constants ¶
View Source
const (
AppName = "http"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuildConfig ¶
type CORS ¶
type CORS struct { Enabled bool `toml:"enabled" json:"enabled" yaml:"enabled" env:"ENABLED"` AllowedHeaders []string `json:"cors_allowed_headers" yaml:"cors_allowed_headers" toml:"cors_allowed_headers" env:"ALLOWED_HEADERS" envSeparator:","` AllowedDomains []string `json:"cors_allowed_domains" yaml:"cors_allowed_domains" toml:"cors_allowed_domains" env:"ALLOWED_DOMAINS" envSeparator:","` AllowedMethods []string `json:"cors_allowed_methods" yaml:"cors_allowed_methods" toml:"cors_allowed_methods" env:"ALLOWED_METHODS" envSeparator:","` }
type GinRouterBuilder ¶
type GinRouterBuilder struct {
// contains filtered or unexported fields
}
func NewGinRouterBuilder ¶
func NewGinRouterBuilder() *GinRouterBuilder
func (*GinRouterBuilder) Config ¶
func (b *GinRouterBuilder) Config(c *BuildConfig)
type GoRestfulRouterBuilder ¶
type GoRestfulRouterBuilder struct {
// contains filtered or unexported fields
}
func NewGoRestfulRouterBuilder ¶
func NewGoRestfulRouterBuilder() *GoRestfulRouterBuilder
func (*GoRestfulRouterBuilder) Build ¶
func (b *GoRestfulRouterBuilder) Build() (http.Handler, error)
func (*GoRestfulRouterBuilder) Config ¶
func (b *GoRestfulRouterBuilder) Config(c *BuildConfig)
type HealthCheck ¶
type HealthCheck struct {
Enabled bool `toml:"enabled" json:"enabled" yaml:"enabled" env:"ENABLED"`
}
type Http ¶
type Http struct { ioc.ObjectImpl // 是否开启HTTP Server, 默认会根据是否有注册得有API对象来自动开启 Enable *bool `json:"enable" yaml:"enable" toml:"enable" env:"ENABLE"` // HTTP服务Host Host string `json:"host" yaml:"host" toml:"host" env:"HOST"` // HTTP服务端口 Port int `json:"port" yaml:"port" toml:"port" env:"PORT"` // API接口前缀 PathPrefix string `json:"path_prefix" yaml:"path_prefix" toml:"path_prefix" env:"PATH_PREFIX"` // 使用的http框架, 默认会根据当前注册的API对象,自动选择合适的框架 WEB_FRAMEWORK WEB_FRAMEWORK `json:"web_framework" yaml:"web_framework" toml:"web_framework" env:"WEB_FRAMEWORK"` // HTTP服务器参数 // HTTP Header读取超时时间 ReadHeaderTimeoutSecond int `json:"read_header_timeout" yaml:"read_header_timeout" toml:"read_header_timeout" env:"READ_HEADER_TIMEOUT"` // 读取HTTP整个请求时的参数 ReadTimeoutSecond int `json:"read_timeout" yaml:"read_timeout" toml:"read_timeout" env:"READ_TIMEOUT"` // 响应超时时间 WriteTimeoutSecond int `json:"write_timeout" yaml:"write_timeout" toml:"write_timeout" env:"WRITE_TIMEOUT"` // 启用了KeepAlive时 复用TCP链接的超时时间 IdleTimeoutSecond int `json:"idle_timeout" yaml:"idle_timeout" toml:"idle_timeout" env:"IDLE_TIMEOUT"` // header最大大小 MaxHeaderSize string `json:"max_header_size" yaml:"max_header_size" toml:"max_header_size" env:"MAX_HEADER_SIZE"` // SSL启用参数 EnableSSL bool `json:"enable_ssl" yaml:"enable_ssl" toml:"enable_ssl" env:"ENABLE_SSL"` CertFile string `json:"cert_file" yaml:"cert_file" toml:"cert_file" env:"CERT_FILE"` KeyFile string `json:"key_file" yaml:"key_file" toml:"key_file" env:"KEY_FILE"` // 开启Trace EnableTrace bool `toml:"enable_trace" json:"enable_trace" yaml:"enable_trace" env:"ENABLE_TRACE"` // 开启HTTP健康检查 HealthCheck HealthCheck `toml:"health_check" json:"health_check" yaml:"health_check" envPrefix:"HEALTH_CHECK_"` // cors配置 Cors CORS `toml:"cors" json:"cors" yaml:"cors" envPrefix:"CORS_"` // API Doc配置 swagger配置 ApiDoc ApiDoc `json:"api_doc" yaml:"api_doc" toml:"api_doc" envPrefix:"API_DOC_"` RouterBuildConfig *BuildConfig `json:"-" yaml:"-" toml:"-" env:"-"` // contains filtered or unexported fields }
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 { Config(*BuildConfig) Build() (http.Handler, error) }
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.