Documentation ¶
Overview ¶
package fusion provides chaing for both fasthttp RequestHandler and RequestHandler based Middleware
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Handlers ¶
func Handlers(hs ...fasthttp.RequestHandler) fasthttp.RequestHandler
Handlers acts as a simple function that
Types ¶
type Middleware ¶
type Middleware func(fasthttp.RequestHandler) fasthttp.RequestHandler
type definition for Middleware that takes in a RequestHandler
type Middlewares ¶
type Middlewares struct {
// contains filtered or unexported fields
}
Abstraction for RequestHandler Middleware slice.
func New ¶
func New(ms ...Middleware) *Middlewares
New creates a new Chain with given Middlewares Middlewares are only called upon a call to Then().
func (*Middlewares) Handler ¶
func (m *Middlewares) Handler(handler fasthttp.RequestHandler) fasthttp.RequestHandler
Handler chains the middlewares and returns the final http.Handler.
New(m1, m2, m3).Handle(h)
is equivalent to:
m1(m2(m3(h)))
When the request comes in, it will be passed m1 -> m2 -> m3 -> handler (assuming every middleware calls the following one).
A chain can be safely reused by calling Handle() several times.
stdStack := fusion.New(ratelimitHandler, csrfHandler) indexPipe = stdStack.Handler(indexHandler) authPipe = stdStack.Handler(authHandler)
For proper middleware, this should cause no problems.
Handler() treats nil as fasthttprouter.New().Handler