package fasthttpadaptor

import "github.com/valyala/fasthttp/fasthttpadaptor"

Package fasthttpadaptor provides helper functions for converting net/http request handlers to fasthttp request handlers.

Index

Functions

func ConvertRequest

func ConvertRequest(ctx *fasthttp.RequestCtx, r *http.Request, forServer bool) error

ConvertRequest convert a fasthttp.Request to an http.Request forServer should be set to true when the http.Request is going to passed to a http.Handler.

func NewFastHTTPHandler

func NewFastHTTPHandler(h http.Handler) fasthttp.RequestHandler

NewFastHTTPHandler wraps net/http handler to fasthttp request handler, so it can be passed to fasthttp server.

While this function may be used for easy switching from net/http to fasthttp, it has the following drawbacks comparing to using manually written fasthttp request handler:

So it is advisable using this function only for quick net/http -> fasthttp switching. Then manually convert net/http handlers to fasthttp handlers according to https://github.com/valyala/fasthttp#switching-from-nethttp-to-fasthttp .

func NewFastHTTPHandlerFunc

func NewFastHTTPHandlerFunc(h http.HandlerFunc) fasthttp.RequestHandler

NewFastHTTPHandlerFunc wraps net/http handler func to fasthttp request handler, so it can be passed to fasthttp server.

While this function may be used for easy switching from net/http to fasthttp, it has the following drawbacks comparing to using manually written fasthttp request handler:

So it is advisable using this function only for quick net/http -> fasthttp switching. Then manually convert net/http handlers to fasthttp handlers according to https://github.com/valyala/fasthttp#switching-from-nethttp-to-fasthttp .

Source Files

adaptor.go request.go

Version
v1.33.0
Published
Jan 27, 2022
Platform
js/wasm
Imports
5 packages
Last checked
3 weeks ago

Tools for package owners.