23 lines
609 B
Go
23 lines
609 B
Go
//go:build fasthttp
|
|
// +build fasthttp
|
|
|
|
package router
|
|
|
|
import "github.com/valyala/fasthttp"
|
|
|
|
// FastHTTPHandler adapts fasthttp handlers to the router.
|
|
type FastHTTPHandler struct {
|
|
ctx *fasthttp.RequestCtx
|
|
h func(ctx *fasthttp.RequestCtx, params []string)
|
|
}
|
|
|
|
// Serve executes the fasthttp handler with parameters.
|
|
func (f *FastHTTPHandler) Serve(params []string) {
|
|
f.h(f.ctx, params)
|
|
}
|
|
|
|
// NewFastHTTP creates a handler from a fasthttp handler function.
|
|
func NewFastHTTP(ctx *fasthttp.RequestCtx, h func(ctx *fasthttp.RequestCtx, params []string)) Handler {
|
|
return &FastHTTPHandler{ctx: ctx, h: h}
|
|
}
|