Documentation
¶
Index ¶
- func WebsocketServerOptionBuffer(read, write int) func(ws.Upgrader)
- func WebsocketServerOptionCompression(enable bool) func(ws.Upgrader)
- func WithHTTP() plugins.Plugin
- func WithHTTPClient() plugins.Plugin
- func WithHTTPDebug() plugins.Plugin
- func WithWebsocketClient() plugins.Plugin
- func WithWebsocketServer(options ...func(ws.Upgrader)) plugins.Plugin
- func WithWebsocketServerPool(options ...func(ws.Upgrader)) plugins.Plugin
- type ClientHttp
- type ConfigDebug
- type ConfigHttp
- type Context
- type Cookie
- type ErrCtx
- type Header
- type Middleware
- type Param
- type RouteCollector
- type Router
- type RouterPool
- type WebsocketClient
- type WebsocketClientConnect
- type WebsocketServer
- type WebsocketServerPool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithHTTPDebug ¶
WithHTTPDebug debug service over HTTP protocol with pprof enabled
func WithWebsocketClient ¶
Types ¶
type ClientHttp ¶
type ClientHttp interface {
Create(opts ...webutil.ClientHttpOption) *webutil.ClientHttp
}
type ConfigDebug ¶
type ConfigDebug struct {
Config webutil.ConfigHttp `yaml:"debug"`
}
ConfigDebug config to initialize HTTP debug service
func (*ConfigDebug) Default ¶
func (v *ConfigDebug) Default()
type ConfigHttp ¶
type ConfigHttp struct {
Config map[string]webutil.ConfigHttp `yaml:"http"`
}
ConfigHttp config to initialize HTTP service
func (*ConfigHttp) Default ¶
func (v *ConfigHttp) Default()
type Context ¶
type Context interface {
URL() *url.URL
Redirect(uri string)
Param(key string) Param
Header() Header
Cookie() Cookie
BindBytes(in *[]byte) error
BindJSON(in interface{}) error
BindXML(in interface{}) error
Error(code int, err error)
ErrorJSON(code int, err error, ctx ErrCtx)
Bytes(code int, b []byte)
String(code int, b string, args ...interface{})
JSON(code int, in interface{})
Stream(code int, in []byte, filename string)
Context() context.Context
Log() log.WriterContext
Request() *http.Request
Response() http.ResponseWriter
}
Context request and response interface
type ErrCtx ¶
type ErrCtx map[string]interface{}
func (ErrCtx) MarshalEasyJSON ¶
MarshalEasyJSON supports easyjson.Marshaler interface
func (ErrCtx) MarshalJSON ¶
MarshalJSON supports json.Marshaler interface
func (*ErrCtx) UnmarshalEasyJSON ¶
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*ErrCtx) UnmarshalJSON ¶
UnmarshalJSON supports json.Unmarshaler interface
type Middleware ¶
type Middleware func(func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request)
Middleware type of middleware
func ThrottlingMiddleware ¶
func ThrottlingMiddleware(max int64) Middleware
ThrottlingMiddleware limits active requests
type RouteCollector ¶
type RouteCollector interface {
Get(path string, call func(ctx Context))
Head(path string, call func(ctx Context))
Post(path string, call func(ctx Context))
Put(path string, call func(ctx Context))
Delete(path string, call func(ctx Context))
Options(path string, call func(ctx Context))
Patch(path string, call func(ctx Context))
Match(path string, call func(ctx Context), methods ...string)
Collection(prefix string, args ...Middleware) RouteCollector
}
RouteCollector interface of the router collection
type Router ¶
type Router interface {
Use(args ...Middleware)
NotFoundHandler(call func(ctx Context))
RouteCollector
}
Router router handler interface
type RouterPool ¶
type RouterPool interface {
//All method to get all route handlers
All(call func(name string, router Router))
//Main method to get Main route handler
Main() Router
//Get method to get route handler by key
Get(name string) Router
}
RouterPool router pool handler
type WebsocketClient ¶
type WebsocketClient interface {
Create(url string, opts ...func(websocket.ClientOption)) WebsocketClientConnect
}
type WebsocketClientConnect ¶ added in v0.13.0
type WebsocketClientConnect interface {
Encode(eid websocket.EventID, in interface{})
ConnectID() string
Header(key, value string)
SetHandler(call websocket.ClientHandler, eids ...websocket.EventID)
DelHandler(eids ...websocket.EventID)
OnClose(cb func(cid string))
OnOpen(cb func(cid string))
Close()
}
type WebsocketServer ¶
type WebsocketServerPool ¶
type WebsocketServerPool interface {
Create(name string) WebsocketServer
}
Click to show internal directories.
Click to hide internal directories.