Documentation
¶
Index ¶
- Constants
- func Healthy(status int)
- func KeepaliveServer(conf KeepaliveConfig) error
- func Monitor(conf *KeepaliveConfig, server *Server) <-chan struct{}
- func NewHttpServe(c ServerConfig, Logger Logger, r RouterAdapter, ...) error
- type Args
- type BufferConfig
- type Client
- type ConfigDecoder
- type ConnConfig
- func (c *ConnConfig) GetConcurrency() int
- func (c *ConnConfig) GetDisableKeepalive() bool
- func (c *ConnConfig) GetIdleTimeout() time.Duration
- func (c *ConnConfig) GetMaxConnsPerIP() int
- func (c *ConnConfig) GetReadTimeout() time.Duration
- func (c *ConnConfig) GetSleepWhenConcurrencyLimitsExceeded() time.Duration
- func (c *ConnConfig) GetWriteTimeout() time.Duration
- type Group
- func (g *Group) ANY(path string, handler RequestHandler)
- func (g *Group) DELETE(path string, handler RequestHandler)
- func (g *Group) GET(path string, handler RequestHandler)
- func (g *Group) Group(path string, middleware ...MiddlewareHandler) *Group
- func (g *Group) HEAD(path string, handler RequestHandler)
- func (g *Group) OPTIONS(path string, handler RequestHandler)
- func (g *Group) PATCH(path string, handler RequestHandler)
- func (g *Group) POST(path string, handler RequestHandler)
- func (g *Group) PUT(path string, handler RequestHandler)
- type Handler
- type HeaderConfig
- type HttpClient
- type HttpClientConfig
- func (h *HttpClientConfig) GetDisableHeaderNamesNormalizing() bool
- func (h *HttpClientConfig) GetDisablePathNormalizing() bool
- func (h *HttpClientConfig) GetMaxConnDuration() time.Duration
- func (h *HttpClientConfig) GetMaxConnWaitTimeout() time.Duration
- func (h *HttpClientConfig) GetMaxConnsPerHost() int
- func (h *HttpClientConfig) GetMaxIdemponentCallAttempts() int
- func (h *HttpClientConfig) GetMaxIdleConnDuration() time.Duration
- func (h *HttpClientConfig) GetMaxResponseBodySize() int
- func (h *HttpClientConfig) GetName() string
- func (h *HttpClientConfig) GetNoDefaultUserAgentHeader() bool
- func (h *HttpClientConfig) GetReadBufferSize() int
- func (h *HttpClientConfig) GetReadTimeout() time.Duration
- func (h *HttpClientConfig) GetWriteBufferSize() int
- func (h *HttpClientConfig) GetWriteTimeout() time.Duration
- type HttpClientHandler
- type HttpClientRequestHandler
- type KeepaliveConfig
- func (k *KeepaliveConfig) GetAddr() string
- func (k *KeepaliveConfig) GetHealthy() int
- func (k *KeepaliveConfig) GetInterval() time.Duration
- func (k *KeepaliveConfig) GetMsg() string
- func (k *KeepaliveConfig) GetPath() string
- func (k *KeepaliveConfig) GetSignal() []os.Signal
- func (k *KeepaliveConfig) GetUnhealthy() int
- type Logger
- type MiddlewareHandler
- type Option
- type Request
- type RequestConfig
- type RequestCtx
- type RequestHandler
- type RequestHeader
- type Response
- type Router
- type RouterAdapter
- type Server
- type ServerConfig
- func (c *ServerConfig) GetAccessLog() *YamlNode
- func (c *ServerConfig) GetBuffer() *BufferConfig
- func (c *ServerConfig) GetConn() *ConnConfig
- func (c *ServerConfig) GetHeader() *HeaderConfig
- func (c *ServerConfig) GetKeepalive() *KeepaliveConfig
- func (c *ServerConfig) GetRequest() *RequestConfig
- func (c *ServerConfig) GetTcp() *TcpConfig
- type SystemConfig
- type TcpConfig
- type URI
- type YamlNode
Constants ¶
View Source
const ( StatusInternalServerError = fasthttp.StatusInternalServerError StatusNotFound = fasthttp.StatusNotFound StatusMethodNotAllowed = fasthttp.StatusMethodNotAllowed )
Variables ¶
This section is empty.
Functions ¶
func KeepaliveServer ¶ added in v1.3.0
func KeepaliveServer(conf KeepaliveConfig) error
func Monitor ¶ added in v1.3.0
func Monitor(conf *KeepaliveConfig, server *Server) <-chan struct{}
func NewHttpServe ¶ added in v1.0.1
func NewHttpServe(c ServerConfig, Logger Logger, r RouterAdapter, options ...func(filter Handler) Handler) error
Types ¶
type BufferConfig ¶
type BufferConfig struct {
ReadBufferSize int `yaml:"read_buffer_size"`
WriteBufferSize int `yaml:"write_buffer_size"`
}
func (*BufferConfig) GetReadBufferSize ¶
func (c *BufferConfig) GetReadBufferSize() int
func (*BufferConfig) GetWriteBufferSize ¶
func (c *BufferConfig) GetWriteBufferSize() int
type Client ¶ added in v1.3.0
type Client struct {
// contains filtered or unexported fields
}
func (*Client) Do ¶ added in v1.3.0
func (c *Client) Do(handler HttpClientHandler)
func (*Client) Request ¶ added in v1.3.0
func (c *Client) Request(uri string, handler HttpClientRequestHandler)
func (*Client) WithOptions ¶ added in v1.3.0
type ConfigDecoder ¶
type ConfigDecoder interface {
Decode(v interface{}) (err error)
}
type ConnConfig ¶
type ConnConfig struct {
Concurrency int `yaml:"concurrency"`
SleepWhenConcurrencyLimitsExceeded int `yaml:"concurrency_limits_wait"`
DisableKeepalive bool `yaml:"disable_keepalive"`
MaxConnsPerIP int `yaml:"max_connections"`
ReadTimeout int `yaml:"read_timeout"`
WriteTimeout int `yaml:"write_timeout"`
IdleTimeout int `yaml:"idle_timeout"`
}
func (*ConnConfig) GetConcurrency ¶
func (c *ConnConfig) GetConcurrency() int
func (*ConnConfig) GetDisableKeepalive ¶
func (c *ConnConfig) GetDisableKeepalive() bool
func (*ConnConfig) GetIdleTimeout ¶
func (c *ConnConfig) GetIdleTimeout() time.Duration
func (*ConnConfig) GetMaxConnsPerIP ¶
func (c *ConnConfig) GetMaxConnsPerIP() int
func (*ConnConfig) GetReadTimeout ¶
func (c *ConnConfig) GetReadTimeout() time.Duration
func (*ConnConfig) GetSleepWhenConcurrencyLimitsExceeded ¶
func (c *ConnConfig) GetSleepWhenConcurrencyLimitsExceeded() time.Duration
func (*ConnConfig) GetWriteTimeout ¶
func (c *ConnConfig) GetWriteTimeout() time.Duration
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
func (*Group) ANY ¶ added in v1.1.0
func (g *Group) ANY(path string, handler RequestHandler)
DELETE is a shortcut for group.Handle(fasthttp.MethodDelete, path, handler)
func (*Group) DELETE ¶ added in v1.1.0
func (g *Group) DELETE(path string, handler RequestHandler)
DELETE is a shortcut for group.Handle(fasthttp.MethodDelete, path, handler)
func (*Group) GET ¶ added in v1.1.0
func (g *Group) GET(path string, handler RequestHandler)
GET is a shortcut for group.Handle(fasthttp.MethodGet, path, handler)
func (*Group) Group ¶ added in v1.1.0
func (g *Group) Group(path string, middleware ...MiddlewareHandler) *Group
func (*Group) HEAD ¶ added in v1.1.0
func (g *Group) HEAD(path string, handler RequestHandler)
HEAD is a shortcut for group.Handle(fasthttp.MethodHead, path, handler)
func (*Group) OPTIONS ¶ added in v1.1.0
func (g *Group) OPTIONS(path string, handler RequestHandler)
OPTIONS is a shortcut for group.Handle(fasthttp.MethodOptions, path, handler)
func (*Group) PATCH ¶ added in v1.1.0
func (g *Group) PATCH(path string, handler RequestHandler)
PATCH is a shortcut for group.Handle(fasthttp.MethodPatch, path, handler)
func (*Group) POST ¶ added in v1.1.0
func (g *Group) POST(path string, handler RequestHandler)
POST is a shortcut for group.Handle(fasthttp.MethodPost, path, handler)
func (*Group) PUT ¶ added in v1.1.0
func (g *Group) PUT(path string, handler RequestHandler)
PUT is a shortcut for group.Handle(fasthttp.MethodPut, path, handler)
type Handler ¶ added in v1.2.0
type Handler = fasthttp.RequestHandler
func AfterHandler ¶ added in v1.2.0
func BeforeHandler ¶ added in v1.2.0
func Middleware ¶ added in v1.2.0
func Middleware(middleware MiddlewareHandler, handler Handler) Handler
type HeaderConfig ¶
type HeaderConfig struct {
Name string `yaml:"server"`
DisableHeaderNamesNormalizing bool `yaml:"disable_header_names_normalizing"`
NoDefaultServerHeader bool `yaml:"no_default_server_header"`
NoDefaultDate bool `yaml:"no_default_date"`
NoDefaultContentType bool `yaml:"no_default_content_type"`
}
func (*HeaderConfig) GetDisableHeaderNamesNormalizing ¶
func (c *HeaderConfig) GetDisableHeaderNamesNormalizing() bool
func (*HeaderConfig) GetNoDefaultContentType ¶
func (c *HeaderConfig) GetNoDefaultContentType() bool
func (*HeaderConfig) GetNoDefaultDate ¶
func (c *HeaderConfig) GetNoDefaultDate() bool
func (*HeaderConfig) GetNoDefaultServerHeader ¶
func (c *HeaderConfig) GetNoDefaultServerHeader() bool
func (*HeaderConfig) GetServer ¶
func (c *HeaderConfig) GetServer() string
type HttpClient ¶ added in v1.3.0
type HttpClientConfig ¶ added in v1.3.0
type HttpClientConfig struct {
Name string
NoDefaultUserAgentHeader bool `yaml:"no_default_ua"`
// Maximum number of connections per each host which may be established.
//
// DefaultMaxConnsPerHost is used if not set.
MaxConnsPerHost int `yaml:"max_conn_host"`
// Idle keep-alive connections are closed after this duration.
//
// By default idle connections are closed
// after DefaultMaxIdleConnDuration.
MaxIdleConnDuration int `yaml:"max_idle_conn_duration"`
// Keep-alive connections are closed after this duration.
//
// By default connection duration is unlimited.
MaxConnDuration int `yaml:"max_conn_duration"`
// Maximum number of attempts for idempotent calls
//
// DefaultMaxIdemponentCallAttempts is used if not set.
MaxIdemponentCallAttempts int `yaml:"max_idemponent_call_attempts"`
// Per-connection buffer size for responses' reading.
// This also limits the maximum header size.
//
// Default buffer size is used if 0.
ReadBufferSize int `yaml:"read_buffer_size"`
// Per-connection buffer size for requests' writing.
//
// Default buffer size is used if 0.
WriteBufferSize int `yaml:"write_buffer_size"`
// Maximum duration for full response reading (including body).
//
// By default response read timeout is unlimited.
ReadTimeout int `yaml:"read_timeout"`
// Maximum duration for full request writing (including body).
//
// By default request write timeout is unlimited.
WriteTimeout int `yaml:"write_timeout"`
// Maximum response body size.
//
// The client returns ErrBodyTooLarge if this limit is greater than 0
// and response body is greater than the limit.
//
// By default response body size is unlimited.
MaxResponseBodySize int `yaml:"max_response_body_size"`
// Header names are passed as-is without normalization
// if this option is set.
//
// Disabled header names' normalization may be useful only for proxying
// responses to other clients expecting case-sensitive
// header names. See https://github.com/valyala/fasthttp/issues/57
// for details.
//
// By default request and response header names are normalized, i.e.
// The first letter and the first letters following dashes
// are uppercased, while all the other letters are lowercased.
// Examples:
//
// * HOST -> Host
// * content-type -> Content-Type
// * cONTENT-lenGTH -> Content-Length
DisableHeaderNamesNormalizing bool `yaml:"disable_header_names_normalizing"`
// Path values are sent as-is without normalization
//
// Disabled path normalization may be useful for proxying incoming requests
// to servers that are expecting paths to be forwarded as-is.
//
// By default path values are normalized, i.e.
// extra slashes are removed, special characters are encoded.
DisablePathNormalizing bool `yaml:"disable_path_normalizing"`
// Maximum duration for waiting for a free connection.
//
// By default will not waiting, return ErrNoFreeConns immediately
MaxConnWaitTimeout int `yaml:"max_conn_wait_timeout"`
}
func ParseClientConfig ¶ added in v1.3.0
func ParseClientConfig(decoder ConfigDecoder) (*HttpClientConfig, error)
func (*HttpClientConfig) GetDisableHeaderNamesNormalizing ¶ added in v1.3.0
func (h *HttpClientConfig) GetDisableHeaderNamesNormalizing() bool
func (*HttpClientConfig) GetDisablePathNormalizing ¶ added in v1.3.0
func (h *HttpClientConfig) GetDisablePathNormalizing() bool
func (*HttpClientConfig) GetMaxConnDuration ¶ added in v1.3.0
func (h *HttpClientConfig) GetMaxConnDuration() time.Duration
func (*HttpClientConfig) GetMaxConnWaitTimeout ¶ added in v1.3.0
func (h *HttpClientConfig) GetMaxConnWaitTimeout() time.Duration
func (*HttpClientConfig) GetMaxConnsPerHost ¶ added in v1.3.0
func (h *HttpClientConfig) GetMaxConnsPerHost() int
func (*HttpClientConfig) GetMaxIdemponentCallAttempts ¶ added in v1.3.0
func (h *HttpClientConfig) GetMaxIdemponentCallAttempts() int
func (*HttpClientConfig) GetMaxIdleConnDuration ¶ added in v1.3.0
func (h *HttpClientConfig) GetMaxIdleConnDuration() time.Duration
func (*HttpClientConfig) GetMaxResponseBodySize ¶ added in v1.3.0
func (h *HttpClientConfig) GetMaxResponseBodySize() int
func (*HttpClientConfig) GetName ¶ added in v1.3.0
func (h *HttpClientConfig) GetName() string
func (*HttpClientConfig) GetNoDefaultUserAgentHeader ¶ added in v1.3.0
func (h *HttpClientConfig) GetNoDefaultUserAgentHeader() bool
func (*HttpClientConfig) GetReadBufferSize ¶ added in v1.3.0
func (h *HttpClientConfig) GetReadBufferSize() int
func (*HttpClientConfig) GetReadTimeout ¶ added in v1.3.0
func (h *HttpClientConfig) GetReadTimeout() time.Duration
func (*HttpClientConfig) GetWriteBufferSize ¶ added in v1.3.0
func (h *HttpClientConfig) GetWriteBufferSize() int
func (*HttpClientConfig) GetWriteTimeout ¶ added in v1.3.0
func (h *HttpClientConfig) GetWriteTimeout() time.Duration
type HttpClientHandler ¶ added in v1.3.0
type HttpClientHandler func(client *HttpClient, request *Request, response *Response) error
type HttpClientRequestHandler ¶ added in v1.3.0
type HttpClientRequestHandler func(client *HttpClient, uri string) (status int, err error)
type KeepaliveConfig ¶ added in v1.3.0
type KeepaliveConfig struct {
Addr string `yaml:"addr"`
Path string `yaml:"path"`
Msg string `yaml:"msg"`
Healthy int `yaml:"healthy"`
Unhealthy int `yaml:"unhealthy"`
Interval int `yaml:"interval"`
Signal []int `yaml:"signal"`
}
func (*KeepaliveConfig) GetAddr ¶ added in v1.3.0
func (k *KeepaliveConfig) GetAddr() string
func (*KeepaliveConfig) GetHealthy ¶ added in v1.3.0
func (k *KeepaliveConfig) GetHealthy() int
func (*KeepaliveConfig) GetInterval ¶ added in v1.3.0
func (k *KeepaliveConfig) GetInterval() time.Duration
func (*KeepaliveConfig) GetMsg ¶ added in v1.3.0
func (k *KeepaliveConfig) GetMsg() string
func (*KeepaliveConfig) GetPath ¶ added in v1.3.0
func (k *KeepaliveConfig) GetPath() string
func (*KeepaliveConfig) GetSignal ¶ added in v1.3.0
func (k *KeepaliveConfig) GetSignal() []os.Signal
func (*KeepaliveConfig) GetUnhealthy ¶ added in v1.3.0
func (k *KeepaliveConfig) GetUnhealthy() int
type MiddlewareHandler ¶ added in v1.2.0
type MiddlewareHandler func(*RequestCtx) error
func LambdaMiddleware ¶ added in v1.2.0
func LambdaMiddleware(handler MiddlewareHandler, h ...MiddlewareHandler) MiddlewareHandler
type Option ¶ added in v1.3.0
type Option interface {
// contains filtered or unexported methods
}
func AddExecutor ¶ added in v1.3.0
func AddExecutor(e func(HttpClientHandler, *HttpClient, *Request, *Response)) Option
func AddRequest ¶ added in v1.3.0
func AddRequest(r func(HttpClientRequestHandler, *HttpClient, string)) Option
func ApplyConfig ¶ added in v1.3.0
func ApplyConfig(c *HttpClientConfig) Option
type RequestConfig ¶
type RequestConfig struct {
MaxRequestsPerConn int `yaml:"max_requests"`
MaxRequestBodySize int `yaml:"max_request_body_size"`
}
func (*RequestConfig) GetMaxRequestBodySize ¶
func (c *RequestConfig) GetMaxRequestBodySize() int
func (*RequestConfig) GetMaxRequestsPerConn ¶
func (c *RequestConfig) GetMaxRequestsPerConn() int
type RequestCtx ¶
type RequestCtx = fasthttp.RequestCtx
type RequestHandler ¶
type RequestHandler = fasthttp.RequestHandler
type RequestHeader ¶ added in v1.3.0
type RequestHeader = fasthttp.RequestHeader
type RouterAdapter ¶
type RouterAdapter interface {
Handler(*RequestCtx)
}
type ServerConfig ¶
type ServerConfig struct {
SystemConfig
Tcp TcpConfig `yaml:"tcp"`
Conn ConnConfig `yaml:"conn"`
Buffer BufferConfig `yaml:"buffer"`
Header HeaderConfig `yaml:"header"`
Request RequestConfig `yaml:"request"`
Keepalive KeepaliveConfig `yaml:"keepalive"`
AccessLog YamlNode `yaml:"access_log"`
}
func ParseConfig ¶
func ParseConfig(decoder ConfigDecoder) (*ServerConfig, error)
func (*ServerConfig) GetAccessLog ¶ added in v1.0.3
func (c *ServerConfig) GetAccessLog() *YamlNode
func (*ServerConfig) GetBuffer ¶
func (c *ServerConfig) GetBuffer() *BufferConfig
func (*ServerConfig) GetConn ¶
func (c *ServerConfig) GetConn() *ConnConfig
func (*ServerConfig) GetHeader ¶
func (c *ServerConfig) GetHeader() *HeaderConfig
func (*ServerConfig) GetKeepalive ¶ added in v1.3.0
func (c *ServerConfig) GetKeepalive() *KeepaliveConfig
func (*ServerConfig) GetRequest ¶
func (c *ServerConfig) GetRequest() *RequestConfig
func (*ServerConfig) GetTcp ¶
func (c *ServerConfig) GetTcp() *TcpConfig
type SystemConfig ¶
type SystemConfig struct {
GetOnly bool `yaml:"get_only"`
DisablePreParseMultipartForm bool `yaml:"disable_multipart_parse"`
ReduceMemoryUsage bool `yaml:"reduce_memory_usage"`
LogAllErrors bool `yaml:"all_errors"`
}
func (*SystemConfig) GetDisablePreParseMultipartForm ¶
func (c *SystemConfig) GetDisablePreParseMultipartForm() bool
func (*SystemConfig) GetLogAllErrors ¶
func (c *SystemConfig) GetLogAllErrors() bool
func (*SystemConfig) GetMethodOnly ¶
func (c *SystemConfig) GetMethodOnly() bool
func (*SystemConfig) GetReduceMemoryUsage ¶
func (c *SystemConfig) GetReduceMemoryUsage() bool
type TcpConfig ¶
type TcpConfig struct {
TCPKeepalive bool `yaml:"tcp_keepalive"`
TCPKeepalivePeriod int `yaml:"tcp_keepalive_interval"`
Addr string `yaml:"addr"`
}
func (*TcpConfig) GetTCPKeepalive ¶
func (*TcpConfig) GetTCPKeepalivePeriod ¶
Click to show internal directories.
Click to hide internal directories.