Documentation
¶
Index ¶
- type HttpServer
- type IPAccessConfig
- type MiddlewareFunc
- type RouteType
- type RouterGroup
- func (g *RouterGroup) Any(p string, handler http.HandlerFunc)
- func (g *RouterGroup) AnyHandler(p string, handler http.Handler)
- func (g *RouterGroup) Connect(p string, handler http.HandlerFunc)
- func (g *RouterGroup) ConnectHandler(p string, handler http.Handler)
- func (g *RouterGroup) Delete(p string, handler http.HandlerFunc)
- func (g *RouterGroup) DeleteHandler(p string, handler http.Handler)
- func (g *RouterGroup) Get(p string, handler http.HandlerFunc)
- func (g *RouterGroup) GetHandler(p string, handler http.Handler)
- func (g *RouterGroup) Group(prefix string) *RouterGroup
- func (g *RouterGroup) Head(p string, handler http.HandlerFunc)
- func (g *RouterGroup) HeadHandler(p string, handler http.Handler)
- func (g *RouterGroup) Options(p string, handler http.HandlerFunc)
- func (g *RouterGroup) OptionsHandler(p string, handler http.Handler)
- func (g *RouterGroup) Patch(p string, handler http.HandlerFunc)
- func (g *RouterGroup) PatchHandler(p string, handler http.Handler)
- func (g *RouterGroup) Post(p string, handler http.HandlerFunc)
- func (g *RouterGroup) PostHandler(p string, handler http.Handler)
- func (g *RouterGroup) Put(p string, handler http.HandlerFunc)
- func (g *RouterGroup) PutHandler(p string, handler http.Handler)
- func (g *RouterGroup) Trace(p string, handler http.HandlerFunc)
- func (g *RouterGroup) TraceHandler(p string, handler http.Handler)
- func (g *RouterGroup) Use(middleware ...MiddlewareFunc) *RouterGroup
- func (g *RouterGroup) Ws(p string, handler func(ws *websocket.Conn))
- type SecurityConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HttpServer ¶
type HttpServer struct {
// 配置属性
ListenAddr string `ini:"listen_addr" json:"listen_addr" yaml:"listen_addr"`
ServerName []string `ini:"server_name,omitempty" json:"server_name" yaml:"server_name"` // 绑定域名
Ssl bool `ini:"ssl" json:"ssl" yaml:"ssl"`
Ca string `ini:"ca" json:"ca" yaml:"ca"`
Crt string `ini:"crt" json:"crt" yaml:"crt"`
Key string `ini:"key" json:"key" yaml:"key"`
SocketTimeout time.Duration `ini:"socket_timeout" json:"socket_timeout" yaml:"socket_timeout"` // socket 心跳超时时间
Hotupdate bool `ini:"hotupdate" json:"hotupdate" yaml:"hotupdate"` // 是否启动热加载
EnableGzip bool `ini:"enable_gzip" json:"enable_gzip" yaml:"enable_gzip"` // 是否开启gzip
Security SecurityConfig `ini:"security" json:"security" yaml:"security"` // 安全配置
Logger zaploger.Config `json:"logger" yaml:"logger" ini:"logger" gorm:"comment:日志配置"`
Allowip []string `ini:"allowip,omitempty" json:"allowip" yaml:"allowip"` // Deprecated: 请使用 addRoute
Denyip []string `ini:"denyip,omitempty" json:"denyip" yaml:"denyip"` // Deprecated: 请使用 addRoute
Route map[string]http.HandlerFunc `yaml:"-" json:"-"` // Deprecated: 请使用 addRoute
RouteHandle map[string]http.Handler `yaml:"-" json:"-"` // Deprecated: 请使用 addRoute
RouteSocket map[string]func(ws *websocket.Conn) `yaml:"-" json:"-"` // Deprecated: 请使用 addRoute
CommonCallback func(w http.ResponseWriter, r *http.Request) bool `yaml:"-" json:"-"` // Deprecated: 请使用 addRoute
// contains filtered or unexported fields
}
func (*HttpServer) Group ¶
func (h *HttpServer) Group(g string) *RouterGroup
func (*HttpServer) HttpServerStart ¶
func (h *HttpServer) HttpServerStart(ctx context.Context)
HttpServerStart 公功 http server 启动函数
type IPAccessConfig ¶
type MiddlewareFunc ¶
MiddlewareFunc 修改为支持 http.Handler
type RouterGroup ¶
type RouterGroup struct {
// contains filtered or unexported fields
}
func (*RouterGroup) Any ¶
func (g *RouterGroup) Any(p string, handler http.HandlerFunc)
func (*RouterGroup) AnyHandler ¶
func (g *RouterGroup) AnyHandler(p string, handler http.Handler)
func (*RouterGroup) Connect ¶
func (g *RouterGroup) Connect(p string, handler http.HandlerFunc)
func (*RouterGroup) ConnectHandler ¶
func (g *RouterGroup) ConnectHandler(p string, handler http.Handler)
func (*RouterGroup) Delete ¶
func (g *RouterGroup) Delete(p string, handler http.HandlerFunc)
func (*RouterGroup) DeleteHandler ¶
func (g *RouterGroup) DeleteHandler(p string, handler http.Handler)
func (*RouterGroup) Get ¶
func (g *RouterGroup) Get(p string, handler http.HandlerFunc)
func (*RouterGroup) GetHandler ¶
func (g *RouterGroup) GetHandler(p string, handler http.Handler)
func (*RouterGroup) Head ¶
func (g *RouterGroup) Head(p string, handler http.HandlerFunc)
func (*RouterGroup) HeadHandler ¶
func (g *RouterGroup) HeadHandler(p string, handler http.Handler)
func (*RouterGroup) Options ¶
func (g *RouterGroup) Options(p string, handler http.HandlerFunc)
func (*RouterGroup) OptionsHandler ¶
func (g *RouterGroup) OptionsHandler(p string, handler http.Handler)
func (*RouterGroup) Patch ¶
func (g *RouterGroup) Patch(p string, handler http.HandlerFunc)
func (*RouterGroup) PatchHandler ¶
func (g *RouterGroup) PatchHandler(p string, handler http.Handler)
func (*RouterGroup) Post ¶
func (g *RouterGroup) Post(p string, handler http.HandlerFunc)
func (*RouterGroup) PostHandler ¶
func (g *RouterGroup) PostHandler(p string, handler http.Handler)
func (*RouterGroup) Put ¶
func (g *RouterGroup) Put(p string, handler http.HandlerFunc)
func (*RouterGroup) PutHandler ¶
func (g *RouterGroup) PutHandler(p string, handler http.Handler)
func (*RouterGroup) Trace ¶
func (g *RouterGroup) Trace(p string, handler http.HandlerFunc)
func (*RouterGroup) TraceHandler ¶
func (g *RouterGroup) TraceHandler(p string, handler http.Handler)
func (*RouterGroup) Use ¶
func (g *RouterGroup) Use(middleware ...MiddlewareFunc) *RouterGroup
Use 支持链式调用
type SecurityConfig ¶
type SecurityConfig struct {
DefaultValidLast bool `ini:"default_valid_last" json:"default_valid_last" yaml:"default_valid_last"` // 默认验证器是否放最后
CORS *cors.Config `ini:"cors" json:"cors" yaml:"cors"` // 跨域配置
IPAccess IPAccessConfig `ini:"ip_access" json:"ip_access" yaml:"ip_access"` // IP访问控制
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.