Middleware chaining for valyala/fasthttp. Works for both:
- Traditional
Middlewares
:func Middleware(h RequestHandler) RequestHandler
- Pure
RequestHandler
:func Handler(ctx *RequestCtx)
This library is very much inspired by [alice]
Sample code:
import (
"github.com/valyala/fasthttp"
"github.com/gofury/fusion"
)
func main() {
router := furyrouter.New()
router.GET("/admin",
// chain handlers is a simple function call
fusion.Handlers(Handler1, Handler2, Handler2)
)
fasthttp.ListenAndServe(":8000",
// chain middleware requires a new struct
fusion.New(Middleware1, Middleware2, Middleware3).Then(router)
)
}