Documentation ¶
Index ¶
- Constants
- func AcquireURL(uri *fasthttp.URI) *stdUrl.URL
- func B2S(b []byte) string
- func ConvertToFastHTTPHandler(handler RequestHandler) fasthttp.RequestHandler
- func ReleaseCtx(ctx *Ctx)
- func ReleaseURL(url *stdUrl.URL)
- func S2B(s string) (b []byte)
- type Config
- type Ctx
- func (ctx *Ctx) Defer(deferFunc func())
- func (ctx *Ctx) JSONBlobResponse(body []byte, statusCode ...int)
- func (ctx *Ctx) JSONInterfaceResponse(data JSONInterface, statusCode ...int)
- func (ctx *Ctx) Next()
- func (ctx *Ctx) PathName() string
- func (ctx *Ctx) RequestID() []byte
- func (ctx *Ctx) ResponseWriter() http.ResponseWriter
- func (ctx *Ctx) URL() *stdUrl.URL
- type JSONInterface
- type Lloyd
- func (r Lloyd) DELETE(path string, handlers ...RequestHandler)
- func (r Lloyd) Defer(handlers ...RequestHandler)
- func (r Lloyd) GET(path string, handlers ...RequestHandler)
- func (r Lloyd) HEAD(path string, handlers ...RequestHandler)
- func (r Lloyd) Handle(method, path string, handlers ...RequestHandler)
- func (r Lloyd) Handler() fasthttp.RequestHandler
- func (r Lloyd) NewGroup(path string) Router
- func (l *Lloyd) NewVirtualHost(hostName string) Router
- func (r Lloyd) PATCH(path string, handlers ...RequestHandler)
- func (r Lloyd) POST(path string, handlers ...RequestHandler)
- func (r Lloyd) PUT(path string, handlers ...RequestHandler)
- func (l *Lloyd) Serve(ln net.Listener) error
- func (l *Lloyd) Shutdown()
- func (r Lloyd) TRACE(path string, handlers ...RequestHandler)
- func (r Lloyd) Use(handlers ...RequestHandler)
- type RequestHandler
- type Router
Constants ¶
const (
XRequestIDHeader = "X-Request-ID"
)
Variables ¶
This section is empty.
Functions ¶
func AcquireURL ¶
AcquirURL returns an url instance from pool
The returned URL may be passed to ReleaseURL when it is no longer needed. It is forbidden accessing url after releasing it
func B2S ¶
B2S converts byte slice to a string without memory allocation. See https://groups.google.com/forum/#!msg/Golang-Nuts/ENgbUzYvCuU/90yGx7GUAgAJ .
func ConvertToFastHTTPHandler ¶
func ConvertToFastHTTPHandler(handler RequestHandler) fasthttp.RequestHandler
func ReleaseCtx ¶
func ReleaseCtx(ctx *Ctx)
ReleaseCtx returns ctx acquired via AcquireCtx to context pool
It is forbidden accessing ctx after releasing it
func ReleaseURL ¶
ReleaseURL returns URL acquired via AcquireURL to pool.
It is forbidden accessing url after releasing it
Types ¶
type Config ¶
type Config struct { //FastHTTP Settings ErrorHandler func(*Ctx, error) Name string Concurrency int DisableKeepalive bool ReadBufferSize int WriteBufferSize int ReadTimeout time.Duration WriteTimeout time.Duration IdleTimeout time.Duration MaxConnsPerIP int MaxRequestsPerConn int MaxKeepaliveDuration time.Duration TCPKeepalive bool TCPKeepalivePeriod time.Duration MaxRequestBodySize int ReduceMemoryUsage bool GetOnly bool DisablePreParseMultipartForm bool LogAllErrors bool DisableHeaderNamesNormalizing bool SleepWhenConcurrencyLimitsExceeded time.Duration NoDefaultServerHeader bool NoDefaultDate bool NoDefaultContentType bool ConnState func(net.Conn, fasthttp.ConnState) Logger fasthttp.Logger KeepHijackedConns bool //Router Settigs SaveMatchedRoutePath bool GlobalOPTIONS RequestHandler NotFound RequestHandler MethodNotAllowed RequestHandler PanicHandler func(*Ctx, interface{}) }
type Ctx ¶
type Ctx struct { *fasthttp.RequestCtx // contains filtered or unexported fields }
Ctx context wrapper of fasthttp.RequestCtx to adds extra funtionality
func AcquireCtx ¶
func AcquireCtx(ctx *fasthttp.RequestCtx) *Ctx
AcquireCtx returns an empty Ctx instance from context pool
The returned Ctx instance may be passed to ReleaseCtx when it is no longer needed. It is forbidden accessing ctx after releasing it
func (*Ctx) Defer ¶
func (ctx *Ctx) Defer(deferFunc func())
Defer appends given function to defer functions list
defer functions will be executed after defer middlewares's executions.
func (*Ctx) JSONBlobResponse ¶
func (*Ctx) JSONInterfaceResponse ¶
func (ctx *Ctx) JSONInterfaceResponse(data JSONInterface, statusCode ...int)
func (*Ctx) Next ¶
func (ctx *Ctx) Next()
When next used, the next handler will be executed after the current handler's execution.
func (*Ctx) ResponseWriter ¶ added in v1.2.0
func (ctx *Ctx) ResponseWriter() http.ResponseWriter
ResponseWriter returns the http.ResponseWriter instance associated with Ctx
type JSONInterface ¶
type Lloyd ¶
type Lloyd struct {
// contains filtered or unexported fields
}
func (Lloyd) DELETE ¶
func (r Lloyd) DELETE(path string, handlers ...RequestHandler)
DELETE is a shortcut for router.Handle(fasthttp.MethodDelete, path, handlers)
func (Lloyd) Defer ¶
func (r Lloyd) Defer(handlers ...RequestHandler)
Defer registers given handlers to router Given handlers will be executed after middlewares and handlers by given order
func (Lloyd) GET ¶
func (r Lloyd) GET(path string, handlers ...RequestHandler)
GET is a shortcut for router.Handle(fasthttp.MethodGet, path, handlers)
func (Lloyd) HEAD ¶
func (r Lloyd) HEAD(path string, handlers ...RequestHandler)
HEAD is a shortcut for router.Handle(fasthttp.MethodHead, path, handlers)
func (Lloyd) Handle ¶
func (r Lloyd) Handle(method, path string, handlers ...RequestHandler)
Handle registers given request handlers with the given path and method There are shortcuts for some methods you can use them.
func (Lloyd) Handler ¶
func (r Lloyd) Handler() fasthttp.RequestHandler
Handler gives routers request handler. Returns un-nil function only if the router is a virtual host router.
func (*Lloyd) NewVirtualHost ¶
NewVirtualHost creates a virtual host for given hostName.
func (Lloyd) PATCH ¶
func (r Lloyd) PATCH(path string, handlers ...RequestHandler)
PATCH is a shortcut for router.Handle(fasthttp.MethodPatch, path, handlers)
func (Lloyd) POST ¶
func (r Lloyd) POST(path string, handlers ...RequestHandler)
POST is a shortcut for router.Handle(fasthttp.MethodPost, path, handlers)
func (Lloyd) PUT ¶
func (r Lloyd) PUT(path string, handlers ...RequestHandler)
PUT is a shortcut for router.Handle(fasthttp.MethodPut, path, handlers)
func (Lloyd) TRACE ¶
func (r Lloyd) TRACE(path string, handlers ...RequestHandler)
TRACE is a shortcut for router.Handle(fasthttp.MethodTrace, path, handlers)
func (Lloyd) Use ¶
func (r Lloyd) Use(handlers ...RequestHandler)
Use registers given middleware handlers to router Given handlers will be executed by given order
type RequestHandler ¶
type RequestHandler func(*Ctx)
func ConvertFastHTTPHandler ¶
func ConvertFastHTTPHandler(handler fasthttp.RequestHandler) RequestHandler
func ConvertStdHTTPHandler ¶
func ConvertStdHTTPHandler(handler http.HandlerFunc) RequestHandler
type Router ¶
type Router interface { // Handle registers given request handlers with the given path and method // There are shortcuts for some methods you can use them. Handle(method string, path string, handlers ...RequestHandler) // Use registers given middleware handlers to router // Given handlers will be executed by given order Use(handlers ...RequestHandler) // Defer registers given handlers to router // Given handlers will be executed after middlewares and handlers by given order Defer(handlers ...RequestHandler) // GET is a shortcut for router.Handle(fasthttp.MethodGet, path, handlers) GET(path string, handlers ...RequestHandler) // POST is a shortcut for router.Handle(fasthttp.MethodPost, path, handlers) POST(path string, handlers ...RequestHandler) // PUT is a shortcut for router.Handle(fasthttp.MethodPut, path, handlers) PUT(path string, handlers ...RequestHandler) // PATCH is a shortcut for router.Handle(fasthttp.MethodPatch, path, handlers) PATCH(path string, handlers ...RequestHandler) // DELETE is a shortcut for router.Handle(fasthttp.MethodDelete, path, handlers) DELETE(path string, handlers ...RequestHandler) // HEAD is a shortcut for router.Handle(fasthttp.MethodHead, path, handlers) HEAD(path string, handlers ...RequestHandler) // TRACE is a shortcut for router.Handle(fasthttp.MethodTrace, path, handlers) TRACE(path string, handlers ...RequestHandler) // Handler gives routers request handler. // Returns un-nil function only if the router is a virtual host router. Handler() fasthttp.RequestHandler // NewGroup creates a subrouter for given path. NewGroup(path string) Router }