🧬 Middleware

Middleware is a function chained in the HTTP request cycle with access to the Context which it uses to perform a specific action, for example, logging every request or enabling CORS.

Fiber Middleware

The Fiber middleware modules listed here are maintained by the Fiber team.

Middleware

Description

Built-in middleware

adaptor

Converter for net/http handlers to/from Fiber request handlers, special thanks to @arsmn!

-

basicauth

Basic auth middleware provides an HTTP basic authentication. It calls the next handler for valid credentials and 401 Unauthorized for missing or invalid credentials.

-

compression

Compression middleware for Fiber, it supports deflate, gzip and brotli by default.

middleware.Compress()

cors

Enable cross-origin resource sharing (CORS) with various options.

-

csrf

Protect from CSRF exploits.

-

embed

FileServer middleware for Fiber, special thanks and credits to Alireza Salary

-

favicon

Ignore favicon from logs or serve from memory if a file path is provided.

middleware.Favicon()

helmet

Helps secure your apps by setting various HTTP headers.

-

jwt

JWT returns a JSON Web Token (JWT) auth middleware.

-

keyauth

Key auth middleware provides a key based authentication.

-

limiter

Rate-limiting middleware for Fiber. Use to limit repeated requests to public APIs and/or endpoints such as password reset.

-

logger

HTTP request/response logger.

middleware.Logger()

pprof

Special thanks to Matthew Lee (@mthli)

-

recover

Recover middleware recovers from panics anywhere in the stack chain and handles the control to the centralized ErrorHandler.

middleware.Recover()

rewrite

Rewrite middleware rewrites the URL path based on provided rules. It can be helpful for backward compatibility or just creating cleaner and more descriptive links.

-

requestid

Request ID middleware generates a unique id for a request.

middleware.RequestID()

session

This session middleware is build on top of fasthttp/session by @savsgio MIT. Special thanks to @thomasvvugt for helping with this middleware.

-

template

This package contains 8 template engines that can be used with Fiber v1.10.x Go version 1.13 or higher is required.

-

websocket

Based on Fasthttp WebSocket for Fiber with Locals support!

-

Third-Party Middleware

These are some additional popular middleware modules created by the community. Please open an issue if you want to see yours.

Middleware

Description

fiber-swagger

Automatically generate RESTful API documentation with Swagger 2.0.

fiber-casbin

Casbin middleware for Fiber

fiber-introspect

Introspection middleware for Fiber

Provides verifying an access token against a remote Introspection endpoint (RFC7662)

fiber_tracing

Middleware that trace requests on Fiber framework with OpenTracing API. You can use every tracer that implement OpenTracing interface

fiber_limiter

fiber_limiter using redis as store for rate limit with two algorithms for choosing sliding window, gcra leaky bucket

fiber-boilerplate

A boilerplate for the Fiber web framework

gqlgen

A Go library for building GraphQL servers without any fuss with Fasthttp support

fiber_limiter

fiber_limiter is implemented with delay calculate of token bucket

Guidelines

Unfinished documentation