middleware/adaptor
import "github.com/gofiber/fiber/v3/middleware/adaptor"
Variables
Source: middleware/adaptor/adaptor.go:294
var (
ErrRemoteAddrEmpty = errors.New("remote address cannot be empty")
ErrRemoteAddrTooLong = errors.New("remote address too long")
)Functions
func ConvertRequest(c fiber.Ctx, forServer bool) (*http.Request, error)
Source: middleware/adaptor/adaptor.go:385
ConvertRequest converts a fiber.Ctx to a http.Request. forServer should be set to true when the http.Request is going to be passed to a http.Handler.
The request is built from the path the router matched (see wiretarget.Routed), which the request line is set to; the returned request's URL and RequestURI alias that line's storage, as they do in fasthttpadaptor, so it is left in place. A routed path fasthttp would read as an authority rather than a path (see wiretarget.ParsesAsPath) is answered with fiber.ErrBadRequest instead of being set, since the request's host would then be read out of it; so is one holding a forged escape (see wiretarget.HasForgedEscape), which URL.Path would decode into a segment the router never matched, and one holding a "%" that begins no escape (see wiretarget.HasStrayPercent), as net/http's server answers it: URL.Path would be the same for "/100%" and "/100%25", which the router keeps apart. A streamed body over the app's BodyLimit returns fiber.ErrRequestEntityTooLarge. The lines of a repeated header are in the order they were received.
func CopyContextToFiberContext(src any, requestContext *fasthttp.RequestCtx)
Source: middleware/adaptor/adaptor.go:409
CopyContextToFiberContext copies the values of context.Context to a fasthttp.RequestCtx. This function safely handles struct fields, using unsafe operations only when necessary for unexported fields.
Deprecated: This function uses reflection and unsafe pointers; consider using explicit context passing.
func FiberApp(app *fiber.App) http.HandlerFunc
Source: middleware/adaptor/adaptor.go:833
FiberApp wraps fiber app to net/http handler func
func FiberHandler(h fiber.Handler) http.Handler
Source: middleware/adaptor/adaptor.go:823
FiberHandler wraps fiber handler to net/http handler
func FiberHandlerFunc(h fiber.Handler) http.HandlerFunc
Source: middleware/adaptor/adaptor.go:828
FiberHandlerFunc wraps fiber handler to net/http handler func
func HTTPHandler(h http.Handler) fiber.Handler
Source: middleware/adaptor/adaptor.go:304
HTTPHandler wraps net/http handler to fiber handler
func HTTPHandlerFunc(h http.HandlerFunc) fiber.Handler
Source: middleware/adaptor/adaptor.go:299
HTTPHandlerFunc wraps net/http handler func to fiber handler
func HTTPHandlerWithContext(h http.Handler) fiber.Handler
Source: middleware/adaptor/adaptor.go:312
HTTPHandlerWithContext is like HTTPHandler, but additionally stores Fiber’s user context in the request context
func HTTPMiddleware(mw func(http.Handler) http.Handler) fiber.Handler
Source: middleware/adaptor/adaptor.go:674
HTTPMiddleware wraps net/http middleware to fiber middleware. The Fiber handlers behind it run after the middleware has returned, so what it does around its call to next (a deferred recover, a replaced r.Body, a deadline) misses them.
func LocalContextFromHTTPRequest(r *http.Request) (context.Context, bool)
Source: middleware/adaptor/adaptor.go:359
LocalContextFromHTTPRequest extracts the Fiber user context previously stored into r.Context() by the adaptor.