http

package
v2.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const (
	AppName = "http"
)

Variables

This section is empty.

Functions

This section is empty.

Types

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服务器参数
	// 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"`

	// 开启Trace
	EnableTrace bool `toml:"enable_trace" json:"enable_trace" yaml:"enable_trace" env:"ENABLE_TRACE"`
	// 开启Trace
	Debug bool `toml:"debug" json:"debug" yaml:"debug" env:"DEBUG"`
	// contains filtered or unexported fields
}

func Get

func Get() *Http

func (*Http) Addr

func (h *Http) Addr() string

func (*Http) ApiObjectAddr added in v2.0.6

func (h *Http) ApiObjectAddr(obj ioc.Object) string

func (*Http) ApiObjectPathPrefix added in v2.0.6

func (h *Http) ApiObjectPathPrefix(obj ioc.Object) string

func (*Http) HTTPPrefix

func (h *Http) HTTPPrefix() string

func (*Http) Init

func (h *Http) Init() error

配置数据解析

func (*Http) IsEnable added in v2.0.8

func (h *Http) IsEnable() bool

func (*Http) Name

func (h *Http) Name() string

func (*Http) Priority added in v2.0.8

func (i *Http) Priority() int

func (*Http) SetRouter added in v2.0.8

func (h *Http) SetRouter(r http.Handler)

func (*Http) Start

func (h *Http) Start(ctx context.Context)

Start 启动服务

func (*Http) Stop

func (h *Http) Stop(ctx context.Context) error

Stop 停止server

func (*Http) SwagerDocs

func (a *Http) SwagerDocs(swo *spec.Swagger)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL