Repository: gofiber/fiber
Pull request #2054 (2022-08-26 23:56:24)

🚀 [Feature]: add envvar expose middleware
## Description

This pr adds environment variable expose middleware.

Fixes https://github.com/gofiber/fiber/issues/2053

## Type of change

Please delete options that are not relevant.

- [X] New feature (non-breaking change which adds functionality)
- [X] This change requires a documentation update

## Checklist:

- [X] For new functionalities I follow the inspiration of the express js framework and built them similar in usage
- [X] I have performed a self-review of my own code
- [X] I have commented my code, particularly in hard-to-understand areas
- [X] I have made corresponding changes to the documentation - https://github.com/gofiber/docs for https://docs.gofiber.io/
- [X] I have added tests that prove my fix is effective or that my feature works
- [X] New and existing unit tests pass locally with my changes
- [X] If new dependencies exist, I have checked that they are really necessary and agreed with the maintainers/community (we want to have as few dependencies as possible)
- [X] I tried to make my code as fast as possible with as few allocations as possible
- [ ] For new code I have written benchmarks so that they can be analyzed and improved


welcome[bot]: Thanks for opening this pull request! 🎉 Please check out our contributing guidelines. If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

efectn: Please update awesome-fiber and https://github.com/gofiber/fiber#-internal-middleware
mstrYoda: > Please update awesome-fiber and https://github.com/gofiber/fiber#-internal-middleware

All done 👍 
efectn: Check actions please. Lgtm
mstrYoda: > Check actions please. Lgtm

I changed `t.Setenv` to `os.Setenv` to provide backward compatibility with older Go versions.

Patch:
diff --git a/.github/README.md b/.github/README.md
index 85406ea9..c0498264 100644
--- a/.github/README.md
+++ b/.github/README.md
@@ -595,13 +595,14 @@ func main() {
 Here is a list of middleware that are included within the Fiber framework.
 
 | Middleware                                                                             | Description                                                                                                                                                                  |
-| :------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+|:---------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
 | [basicauth](https://github.com/gofiber/fiber/tree/master/middleware/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.        |
 | [cache](https://github.com/gofiber/fiber/tree/master/middleware/cache)                 | Intercept and cache responses                                                                                                                                                |
 | [compress](https://github.com/gofiber/fiber/tree/master/middleware/compress)           | Compression middleware for Fiber, it supports `deflate`, `gzip` and `brotli` by default.                                                                                     |
 | [cors](https://github.com/gofiber/fiber/tree/master/middleware/cors)                   | Enable cross-origin resource sharing \(CORS\) with various options.                                                                                                          |
 | [csrf](https://github.com/gofiber/fiber/tree/master/middleware/csrf)                   | Protect from CSRF exploits.                                                                                                                                                  |
 | [encryptcookie](https://github.com/gofiber/fiber/tree/master/middleware/encryptcookie) | Encrypt middleware which encrypts cookie values.                                                                                                                             |
+| [envvar](https://github.com/gofiber/fiber/tree/master/middleware/envvar)               | Expose environment variables with providing an optional config.                                                                                                              |
 | [etag](https://github.com/gofiber/fiber/tree/master/middleware/etag)                   | ETag middleware that lets caches be more efficient and save bandwidth, as a web server does not need to resend a full response if the content has not changed.               |
 | [expvar](https://github.com/gofiber/fiber/tree/master/middleware/expvar)               | Expvar middleware that serves via its HTTP server runtime exposed variants in the JSON format.                                                                               |
 | [favicon](https://github.com/gofiber/fiber/tree/master/middleware/favicon)             | Ignore favicon from logs or serve from memory if a file path is provided.                                                                                                    |
diff --git a/.github/README_ckb.md b/.github/README_ckb.md
index 8fd7ae8d..1f1bfd36 100644
--- a/.github/README_ckb.md
+++ b/.github/README_ckb.md
@@ -601,6 +601,7 @@ func main() {
 | [cors](https://github.com/gofiber/fiber/tree/master/middleware/cors)                   | Enable cross-origin resource sharing \(CORS\) with various options.                                                                                                          |
 | [csrf](https://github.com/gofiber/fiber/tree/master/middleware/csrf)                   | Protect from CSRF exploits.                                                                                                                                                  |
 | [encryptcookie](https://github.com/gofiber/fiber/tree/master/middleware/encryptcookie) | Encrypt middleware which encrypts cookie values.                                                                                                                             |
+| [envvar](https://github.com/gofiber/fiber/tree/master/middleware/envvar)               | Expose environment variables with providing an optional config.                                                                                                              |
 | [etag](https://github.com/gofiber/fiber/tree/master/middleware/etag)                   | ETag middleware that lets caches be more efficient and save bandwidth, as a web server does not need to resend a full response if the content has not changed.               |
 | [expvar](https://github.com/gofiber/fiber/tree/master/middleware/expvar)               | Expvar middleware that serves via its HTTP server runtime exposed variants in the JSON format.                                                                               |
 | [favicon](https://github.com/gofiber/fiber/tree/master/middleware/favicon)             | Ignore favicon from logs or serve from memory if a file path is provided.                                                                                                    |
diff --git a/.github/README_de.md b/.github/README_de.md
index 8964567e..083fb17a 100644
--- a/.github/README_de.md
+++ b/.github/README_de.md
@@ -571,6 +571,7 @@ Hier finden Sie eine Liste der Middleware, die im Fiber-Framework enthalten ist.
 | [cors](https://github.com/gofiber/fiber/tree/master/middleware/cors)                   | Enable cross-origin resource sharing \(CORS\) with various options.                                                                                                          |
 | [csrf](https://github.com/gofiber/fiber/tree/master/middleware/csrf)                   | Protect from CSRF exploits.                                                                                                                                                  |
 | [encryptcookie](https://github.com/gofiber/fiber/tree/master/middleware/encryptcookie) | Encrypt middleware which encrypts cookie values.                                                                                                                             |
+| [envvar](https://github.com/gofiber/fiber/tree/master/middleware/envvar)               | Expose environment variables with providing an optional config.                                                                                                              |
 | [etag](https://github.com/gofiber/fiber/tree/master/middleware/etag)                   | ETag middleware that lets caches be more efficient and save bandwidth, as a web server does not need to resend a full response if the content has not changed.               |
 | [expvar](https://github.com/gofiber/fiber/tree/master/middleware/expvar)               | Expvar middleware that serves via its HTTP server runtime exposed variants in the JSON format.                                                                               |
 | [favicon](https://github.com/gofiber/fiber/tree/master/middleware/favicon)             | Ignore favicon from logs or serve from memory if a file path is provided.                                                                                                    |
diff --git a/.github/README_es.md b/.github/README_es.md
index 29416f26..1803de9f 100644
--- a/.github/README_es.md
+++ b/.github/README_es.md
@@ -571,6 +571,7 @@ Aquí está una lista del middleware incluido en el marco web Fiber.
 | [cors](https://github.com/gofiber/fiber/tree/master/middleware/cors)                   | Enable cross-origin resource sharing \(CORS\) with various options.                                                                                                          |
 | [csrf](https://github.com/gofiber/fiber/tree/master/middleware/csrf)                   | Protect from CSRF exploits.                                                                                                                                                  |
 | [encryptcookie](https://github.com/gofiber/fiber/tree/master/middleware/encryptcookie) | Encrypt middleware which encrypts cookie values.                                                                                                                             |
+| [envvar](https://github.com/gofiber/fiber/tree/master/middleware/envvar)               | Expose environment variables with providing an optional config.                                                                                                              |
 | [etag](https://github.com/gofiber/fiber/tree/master/middleware/etag)                   | ETag middleware that lets caches be more efficient and save bandwidth, as a web server does not need to resend a full response if the content has not changed.               |
 | [expvar](https://github.com/gofiber/fiber/tree/master/middleware/expvar)               | Expvar middleware that serves via its HTTP server runtime exposed variants in the JSON format.                                                                               |
 | [favicon](https://github.com/gofiber/fiber/tree/master/middleware/favicon)             | Ignore favicon from logs or serve from memory if a file path is provided.                                                                                                    |
diff --git a/.github/README_fa.md b/.github/README_fa.md
index 90332c3c..fb555ed4 100644
--- a/.github/README_fa.md
+++ b/.github/README_fa.md
@@ -686,6 +686,7 @@ func main() {
 | [cors](https://github.com/gofiber/fiber/tree/master/middleware/cors)                   |فعال سازی هدر های cross-origin با گزینه های مختلف.|
 | [csrf](https://github.com/gofiber/fiber/tree/master/middleware/csrf)                   |در برابر حملات CSRF ایمنی ایجاد میکند.|
 | [encryptcookie](https://github.com/gofiber/fiber/tree/master/middleware/encryptcookie) |مقادیر کوکی هارا رمزنگاری میکند.|
+| [envvar](https://github.com/gofiber/fiber/tree/master/middleware/envvar)               | با ارائه تنظیمات اختیاری، متغیرهای محیط را در معرض دید قرار دهید.                                                                                                              |
 | [etag](https://github.com/gofiber/fiber/tree/master/middleware/etag)                   | میدلور ETag به کش ها اجازه میدهد کارآمد تر عمل کرده و در پهنای باند صرفه جویی کنند.  به عنوان یک وب سرور نیازی به دادن پاسخ کامل نیست اگر محتوا تغییر نکرده باشد. |
 | [expvar](https://github.com/gofiber/fiber/tree/master/middleware/expvar)               | میدلور Expvar میتواند متغیر هایی را تعریف کرده و مقادیر انها را در زمان اجرا با فرمت JSON به شما نشان دهد. |
 | [favicon](https://github.com/gofiber/fiber/tree/master/middleware/favicon)             | جلوگیری و یا کش کردن درخواست های favicon در صورتی که مسیر یک فایل را داده باشید.|
diff --git a/.github/README_fr.md b/.github/README_fr.md
index ebb24e34..b2fc3732 100644
--- a/.github/README_fr.md
+++ b/.github/README_fr.md
@@ -573,6 +573,7 @@ Here is a list of middleware that are included within the Fiber framework.
 | [cors](https://github.com/gofiber/fiber/tree/master/middleware/cors)                   | Enable cross-origin resource sharing \(CORS\) with various options.                                                                                                          |
 | [csrf](https://github.com/gofiber/fiber/tree/master/middleware/csrf)                   | Protect from CSRF exploits.                                                                                                                                                  |
 | [encryptcookie](https://github.com/gofiber/fiber/tree/master/middleware/encryptcookie) | Encrypt middleware which encrypts cookie values.                                                                                                                             |
+| [envvar](https://github.com/gofiber/fiber/tree/master/middleware/envvar)               | Expose environment variables with providing an optional config.                                                                                                              |
 | [etag](https://github.com/gofiber/fiber/tree/master/middleware/etag)                   | ETag middleware that lets caches be more efficient and save bandwidth, as a web server does not need to resend a full response if the content has not changed.               |
 | [expvar](https://github.com/gofiber/fiber/tree/master/middleware/expvar)               | Expvar middleware that serves via its HTTP server runtime exposed variants in the JSON format.                                                                               |
 | [favicon](https://github.com/gofiber/fiber/tree/master/middleware/favicon)             | Ignore favicon from logs or serve from memory if a file path is provided.                                                                                                    |
diff --git a/.github/README_he.md b/.github/README_he.md
index c6870387..7b19957e 100644
--- a/.github/README_he.md
+++ b/.github/README_he.md
@@ -689,6 +689,7 @@ Here is a list of middleware that are included within the Fiber framework.
 | [cors](https://github.com/gofiber/fiber/tree/master/middleware/cors)                   | Enable cross-origin resource sharing \(CORS\) with various options.                                                                                                          |
 | [csrf](https://github.com/gofiber/fiber/tree/master/middleware/csrf)                   | Protect from CSRF exploits.                                                                                                                                                  |
 | [encryptcookie](https://github.com/gofiber/fiber/tree/master/middleware/encryptcookie) | Encrypt middleware which encrypts cookie values.                                                                                                                             |
+| [envvar](https://github.com/gofiber/fiber/tree/master/middleware/envvar)               | Expose environment variables with providing an optional config.                                                                                                              |
 | [etag](https://github.com/gofiber/fiber/tree/master/middleware/etag)                   | ETag middleware that lets caches be more efficient and save bandwidth, as a web server does not need to resend a full response if the content has not changed.               |
 | [expvar](https://github.com/gofiber/fiber/tree/master/middleware/expvar)               | Expvar middleware that serves via its HTTP server runtime exposed variants in the JSON format.                                                                               |
 | [favicon](https://github.com/gofiber/fiber/tree/master/middleware/favicon)             | Ignore favicon from logs or serve from memory if a file path is provided.                                                                                                    |
diff --git a/.github/README_id.md b/.github/README_id.md
index 6e3e41c5..285644b8 100644
--- a/.github/README_id.md
+++ b/.github/README_id.md
@@ -574,6 +574,7 @@ Kumpulan `middleware` yang ada didalam kerangka kerja Fiber.
 | [cors](https://github.com/gofiber/fiber/tree/master/middleware/cors)                   | Enable cross-origin resource sharing \(CORS\) with various options.                                                                                                          |
 | [csrf](https://github.com/gofiber/fiber/tree/master/middleware/csrf)                   | Protect from CSRF exploits.                                                                                                                                                  |
 | [encryptcookie](https://github.com/gofiber/fiber/tree/master/middleware/encryptcookie) | Encrypt middleware which encrypts cookie values.                                                                                                                             |
+| [envvar](https://github.com/gofiber/fiber/tree/master/middleware/envvar)               | Expose environment variables with providing an optional config.                                                                                                              |
 | [etag](https://github.com/gofiber/fiber/tree/master/middleware/etag)                   | ETag middleware that lets caches be more efficient and save bandwidth, as a web server does not need to resend a full response if the content has not changed.               |
 | [expvar](https://github.com/gofiber/fiber/tree/master/middleware/expvar)               | Expvar middleware that serves via its HTTP server runtime exposed variants in the JSON format.                                                                               |
 | [favicon](https://github.com/gofiber/fiber/tree/master/middleware/favicon)             | Ignore favicon from logs or serve from memory if a file path is provided.                                                                                                    |
diff --git a/.github/README_it.md b/.github/README_it.md
index a07aa84d..b2e6307a 100644
--- a/.github/README_it.md
+++ b/.github/README_it.md
@@ -589,28 +589,29 @@ func main() {
 
 Qui una lista dei middleware inclusi con Fiber.
 
-| Middleware                                                                             | Descrizione                                                                                                                                                                  |
-| :------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| [basicauth](https://github.com/gofiber/fiber/tree/master/middleware/basicauth)         | Middleware basico di autenticazione usando http. Chiama il suo handler se le credenziali sono guiste e il codice 401 Unauthorized per credenziali mancanti o invailde.        |
-| [cache](https://github.com/gofiber/fiber/tree/master/middleware/cache)                 | Intercetta e mette nella cache la risposta                                                                                                                                                |
-| [compress](https://github.com/gofiber/fiber/tree/master/middleware/compress)           | Middlewere di compressione per Fiber, supporta `deflate`, `gzip` e `brotli` di default.                                                                                     |
+| Middleware                                                                             | Descrizione                                                                                                                                                                              |
+| :------------------------------------------------------------------------------------- |:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| [basicauth](https://github.com/gofiber/fiber/tree/master/middleware/basicauth)         | Middleware basico di autenticazione usando http. Chiama il suo handler se le credenziali sono guiste e il codice 401 Unauthorized per credenziali mancanti o invailde.                   |
+| [cache](https://github.com/gofiber/fiber/tree/master/middleware/cache)                 | Intercetta e mette nella cache la risposta                                                                                                                                               |
+| [compress](https://github.com/gofiber/fiber/tree/master/middleware/compress)           | Middlewere di compressione per Fiber, supporta `deflate`, `gzip` e `brotli` di default.                                                                                                  |
 | [cors](https://github.com/gofiber/fiber/tree/master/middleware/cors)                   | Ti permette di usare cross-origin resource sharing \(CORS\) con tante optzioni.                                                                                                          |
-| [csrf](https://github.com/gofiber/fiber/tree/master/middleware/csrf)                   | Ti protegge da attachi CSRF.                                                                                                                                                  |
-| [encryptcookie](https://github.com/gofiber/fiber/tree/master/middleware/encryptcookie) | Middleware che encrypta i valori dei cookie.                                                                                                                             |
-| [etag](https://github.com/gofiber/fiber/tree/master/middleware/etag)                   | Middlewere che permette alle cache di essere piu efficienti e salvare banda, come un web server non deve rimandare il messagio pieno se il contenuto non è cambiato.               |
-| [expvar](https://github.com/gofiber/fiber/tree/master/middleware/expvar)               | Middleware che serve via il suo runtime server HTTP varianti esposte in formato JSON.                                                                               |
-| [favicon](https://github.com/gofiber/fiber/tree/master/middleware/favicon)             | Ignora favicon dai logs o serve dalla memoria se un filepath si dà.                                                                                                    |
-| [filesystem](https://github.com/gofiber/fiber/tree/master/middleware/filesystem)       | Middleware per il FileSystem per Fiber, grazie tante e crediti a Alireza Salary                                                                                                |
-| [limiter](https://github.com/gofiber/fiber/tree/master/middleware/limiter)             | Middelwere per Rate-limiting per Fiber. Usato per limitare richieste continue agli APIs publici e/o endpoints come un password reset.                                                   |
-| [logger](https://github.com/gofiber/fiber/tree/master/middleware/logger)               | Logger HTTP per richiesta/risposta.                                                                                                                                                |
-| [monitor](https://github.com/gofiber/fiber/tree/master/middleware/monitor)             | Middleware per monitorare che riporta metriche server, ispirato da express-status-monitor                                                                                           |
-| [pprof](https://github.com/gofiber/fiber/tree/master/middleware/pprof)                 | Grazie tante a Matthew Lee \(@mthli\)                                                                                                                                     |
-| [proxy](https://github.com/gofiber/fiber/tree/master/middleware/proxy)                 | Ti permette di fare richieste proxy a multipli server.                                                                                                                           |
-| [recover](https://github.com/gofiber/fiber/tree/master/middleware/recover)             | Middleware per recuperare dai attachi di panico da tutte le parti nella stack chain e da il controllo al centralizzato[ ErrorHandler](https://docs.gofiber.io/guide/error-handling). |
-| [requestid](https://github.com/gofiber/fiber/tree/master/middleware/requestid)         | Aggiunge un requestid a ogni richiesta.                                                                                                                                           |
+| [csrf](https://github.com/gofiber/fiber/tree/master/middleware/csrf)                   | Ti protegge da attachi CSRF.                                                                                                                                                             |
+| [encryptcookie](https://github.com/gofiber/fiber/tree/master/middleware/encryptcookie) | Middleware che encrypta i valori dei cookie.                                                                                                                                             |
+| [envvar](https://github.com/gofiber/fiber/tree/master/middleware/envvar)               | Esporre le variabili di ambiente fornendo una configurazione facoltativa.                                                                                                                |
+| [etag](https://github.com/gofiber/fiber/tree/master/middleware/etag)                   | Middlewere che permette alle cache di essere piu efficienti e salvare banda, come un web server non deve rimandare il messagio pieno se il contenuto non è cambiato.                     |
+| [expvar](https://github.com/gofiber/fiber/tree/master/middleware/expvar)               | Middleware che serve via il suo runtime server HTTP varianti esposte in formato JSON.                                                                                                    |
+| [favicon](https://github.com/gofiber/fiber/tree/master/middleware/favicon)             | Ignora favicon dai logs o serve dalla memoria se un filepath si dà.                                                                                                                      |
+| [filesystem](https://github.com/gofiber/fiber/tree/master/middleware/filesystem)       | Middleware per il FileSystem per Fiber, grazie tante e crediti a Alireza Salary                                                                                                          |
+| [limiter](https://github.com/gofiber/fiber/tree/master/middleware/limiter)             | Middelwere per Rate-limiting per Fiber. Usato per limitare richieste continue agli APIs publici e/o endpoints come un password reset.                                                    |
+| [logger](https://github.com/gofiber/fiber/tree/master/middleware/logger)               | Logger HTTP per richiesta/risposta.                                                                                                                                                      |
+| [monitor](https://github.com/gofiber/fiber/tree/master/middleware/monitor)             | Middleware per monitorare che riporta metriche server, ispirato da express-status-monitor                                                                                                |
+| [pprof](https://github.com/gofiber/fiber/tree/master/middleware/pprof)                 | Grazie tante a Matthew Lee \(@mthli\)                                                                                                                                                    |
+| [proxy](https://github.com/gofiber/fiber/tree/master/middleware/proxy)                 | Ti permette di fare richieste proxy a multipli server.                                                                                                                                   |
+| [recover](https://github.com/gofiber/fiber/tree/master/middleware/recover)             | Middleware per recuperare dai attachi di panico da tutte le parti nella stack chain e da il controllo al centralizzato[ ErrorHandler](https://docs.gofiber.io/guide/error-handling).     |
+| [requestid](https://github.com/gofiber/fiber/tree/master/middleware/requestid)         | Aggiunge un requestid a ogni richiesta.                                                                                                                                                  |
 | [session](https://github.com/gofiber/fiber/tree/master/middleware/session)             | Middelwere per sessioni. NOTA: Questo middleware usa il nostro Storage package.                                                                                                          |
-| [skip](https://github.com/gofiber/fiber/tree/master/middleware/skip)                   | Middleware che salta un wrapped handler se un predicate è vero.                                                                                                         |
-| [timeout](https://github.com/gofiber/fiber/tree/master/middleware/timeout)             | Aggiunge un tempo massimo per una richiesta e lo manda a ErrorHandler se si supera.                                                                                                |
+| [skip](https://github.com/gofiber/fiber/tree/master/middleware/skip)                   | Middleware che salta un wrapped handler se un predicate è vero.                                                                                                                          |
+| [timeout](https://github.com/gofiber/fiber/tree/master/middleware/timeout)             | Aggiunge un tempo massimo per una richiesta e lo manda a ErrorHandler se si supera.                                                                                                      |
 
 ## 🧬 Middleware Esterni
 
diff --git a/.github/README_ja.md b/.github/README_ja.md
index 6d2cda52..8243b292 100644
--- a/.github/README_ja.md
+++ b/.github/README_ja.md
@@ -576,6 +576,7 @@ func main() {
 | [cors](https://github.com/gofiber/fiber/tree/master/middleware/cors)                   | Enable cross-origin resource sharing \(CORS\) with various options.                                                                                                          |
 | [csrf](https://github.com/gofiber/fiber/tree/master/middleware/csrf)                   | Protect from CSRF exploits.                                                                                                                                                  |
 | [encryptcookie](https://github.com/gofiber/fiber/tree/master/middleware/encryptcookie) | Encrypt middleware which encrypts cookie values.                                                                                                                             |
+| [envvar](https://github.com/gofiber/fiber/tree/master/middleware/envvar)               | Expose environment variables with providing an optional config.                                                                                                              |
 | [etag](https://github.com/gofiber/fiber/tree/master/middleware/etag)                   | ETag middleware that lets caches be more efficient and save bandwidth, as a web server does not need to resend a full response if the content has not changed.               |
 | [expvar](https://github.com/gofiber/fiber/tree/master/middleware/expvar)               | Expvar middleware that serves via its HTTP server runtime exposed variants in the JSON format.                                                                               |
 | [favicon](https://github.com/gofiber/fiber/tree/master/middleware/favicon)             | Ignore favicon from logs or serve from memory if a file path is provided.                                                                                                    |
diff --git a/.github/README_ko.md b/.github/README_ko.md
index 6b4ba34f..00cea280 100644
--- a/.github/README_ko.md
+++ b/.github/README_ko.md
@@ -577,6 +577,7 @@ Fiber 프레임워크에 포함되는 미들웨어 목록입니다.
 | [cors](https://github.com/gofiber/fiber/tree/master/middleware/cors)                   | Enable cross-origin resource sharing \(CORS\) with various options.                                                                                                          |
 | [csrf](https://github.com/gofiber/fiber/tree/master/middleware/csrf)                   | Protect from CSRF exploits.                                                                                                                                                  |
 | [encryptcookie](https://github.com/gofiber/fiber/tree/master/middleware/encryptcookie) | Encrypt middleware which encrypts cookie values.                                                                                                                             |
+| [envvar](https://github.com/gofiber/fiber/tree/master/middleware/envvar)               | Expose environment variables with providing an optional config.                                                                                                              |
 | [etag](https://github.com/gofiber/fiber/tree/master/middleware/etag)                   | ETag middleware that lets caches be more efficient and save bandwidth, as a web server does not need to resend a full response if the content has not changed.               |
 | [expvar](https://github.com/gofiber/fiber/tree/master/middleware/expvar)               | Expvar middleware that serves via its HTTP server runtime exposed variants in the JSON format.                                                                               |
 | [favicon](https://github.com/gofiber/fiber/tree/master/middleware/favicon)             | Ignore favicon from logs or serve from memory if a file path is provided.                                                                                                    |
diff --git a/.github/README_nl.md b/.github/README_nl.md
index d7ffd4da..000a3787 100644
--- a/.github/README_nl.md
+++ b/.github/README_nl.md
@@ -577,6 +577,7 @@ Here is a list of middleware that are included within the Fiber framework.
 | [cors](https://github.com/gofiber/fiber/tree/master/middleware/cors)                   | Enable cross-origin resource sharing \(CORS\) with various options.                                                                                                          |
 | [csrf](https://github.com/gofiber/fiber/tree/master/middleware/csrf)                   | Protect from CSRF exploits.                                                                                                                                                  |
 | [encryptcookie](https://github.com/gofiber/fiber/tree/master/middleware/encryptcookie) | Encrypt middleware which encrypts cookie values.                                                                                                                             |
+| [envvar](https://github.com/gofiber/fiber/tree/master/middleware/envvar)               | Expose environment variables with providing an optional config.                                                                                                              |
 | [etag](https://github.com/gofiber/fiber/tree/master/middleware/etag)                   | ETag middleware that lets caches be more efficient and save bandwidth, as a web server does not need to resend a full response if the content has not changed.               |
 | [expvar](https://github.com/gofiber/fiber/tree/master/middleware/expvar)               | Expvar middleware that serves via its HTTP server runtime exposed variants in the JSON format.                                                                               |
 | [favicon](https://github.com/gofiber/fiber/tree/master/middleware/favicon)             | Ignore favicon from logs or serve from memory if a file path is provided.                                                                                                    |
diff --git a/.github/README_pt.md b/.github/README_pt.md
index f15f4e3a..0079eb63 100644
--- a/.github/README_pt.md
+++ b/.github/README_pt.md
@@ -571,6 +571,7 @@ Here is a list of middleware that are included within the Fiber framework.
 | [cors](https://github.com/gofiber/fiber/tree/master/middleware/cors)                   | Enable cross-origin resource sharing \(CORS\) with various options.                                                                                                          |
 | [csrf](https://github.com/gofiber/fiber/tree/master/middleware/csrf)                   | Protect from CSRF exploits.                                                                                                                                                  |
 | [encryptcookie](https://github.com/gofiber/fiber/tree/master/middleware/encryptcookie) | Encrypt middleware which encrypts cookie values.                                                                                                                             |
+| [envvar](https://github.com/gofiber/fiber/tree/master/middleware/envvar)               | Expose environment variables with providing an optional config.                                                                                                              |
 | [etag](https://github.com/gofiber/fiber/tree/master/middleware/etag)                   | ETag middleware that lets caches be more efficient and save bandwidth, as a web server does not need to resend a full response if the content has not changed.               |
 | [expvar](https://github.com/gofiber/fiber/tree/master/middleware/expvar)               | Expvar middleware that serves via its HTTP server runtime exposed variants in the JSON format.                                                                               |
 | [favicon](https://github.com/gofiber/fiber/tree/master/middleware/favicon)             | Ignore favicon from logs or serve from memory if a file path is provided.                                                                                                    |
diff --git a/.github/README_ru.md b/.github/README_ru.md
index eaa171ee..12cd17cf 100644
--- a/.github/README_ru.md
+++ b/.github/README_ru.md
@@ -578,6 +578,7 @@ func main() {
 | [cors](https://github.com/gofiber/fiber/tree/master/middleware/cors)                   | Enable cross-origin resource sharing \(CORS\) with various options.                                                                                                          |
 | [csrf](https://github.com/gofiber/fiber/tree/master/middleware/csrf)                   | Protect from CSRF exploits.                                                                                                                                                  |
 | [encryptcookie](https://github.com/gofiber/fiber/tree/master/middleware/encryptcookie) | Encrypt middleware which encrypts cookie values.                                                                                                                             |
+| [envvar](https://github.com/gofiber/fiber/tree/master/middleware/envvar)               | Expose environment variables with providing an optional config.                                                                                                              |
 | [etag](https://github.com/gofiber/fiber/tree/master/middleware/etag)                   | ETag middleware that lets caches be more efficient and save bandwidth, as a web server does not need to resend a full response if the content has not changed.               |
 | [expvar](https://github.com/gofiber/fiber/tree/master/middleware/expvar)               | Expvar middleware that serves via its HTTP server runtime exposed variants in the JSON format.                                                                               |
 | [favicon](https://github.com/gofiber/fiber/tree/master/middleware/favicon)             | Ignore favicon from logs or serve from memory if a file path is provided.                                                                                                    |
diff --git a/.github/README_sa.md b/.github/README_sa.md
index 6e90ca81..b3655d8d 100644
--- a/.github/README_sa.md
+++ b/.github/README_sa.md
@@ -642,6 +642,7 @@ Here is a list of middleware that are included within the Fiber framework.
 | [cors](https://github.com/gofiber/fiber/tree/master/middleware/cors)                   | Enable cross-origin resource sharing \(CORS\) with various options.                                                                                                          |
 | [csrf](https://github.com/gofiber/fiber/tree/master/middleware/csrf)                   | Protect from CSRF exploits.                                                                                                                                                  |
 | [encryptcookie](https://github.com/gofiber/fiber/tree/master/middleware/encryptcookie) | Encrypt middleware which encrypts cookie values.                                                                                                                             |
+| [envvar](https://github.com/gofiber/fiber/tree/master/middleware/envvar)               | Expose environment variables with providing an optional config.                                                                                                              |
 | [etag](https://github.com/gofiber/fiber/tree/master/middleware/etag)                   | ETag middleware that lets caches be more efficient and save bandwidth, as a web server does not need to resend a full response if the content has not changed.               |
 | [expvar](https://github.com/gofiber/fiber/tree/master/middleware/expvar)               | Expvar middleware that serves via its HTTP server runtime exposed variants in the JSON format.                                                                               |
 | [favicon](https://github.com/gofiber/fiber/tree/master/middleware/favicon)             | Ignore favicon from logs or serve from memory if a file path is provided.                                                                                                    |
diff --git a/.github/README_tr.md b/.github/README_tr.md
index 3866ff7c..7f53a7f7 100644
--- a/.github/README_tr.md
+++ b/.github/README_tr.md
@@ -564,26 +564,27 @@ func main() {
 Fiber'a dahil edilen middlewareların bir listesi aşağıda verilmiştir.
 
 | Middleware                                                                             | Açıklama                                                                                                                                                                               |
-| :------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| :------------------------------------------------------------------------------------- |:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
 | [basicauth](https://github.com/gofiber/fiber/tree/master/middleware/basicauth)         | Basic auth middleware'ı, bir HTTP Basic auth sağlar. Geçerli kimlik bilgileri için sonraki handlerı ve eksik veya geçersiz kimlik bilgileri için 401 döndürür.                         |
-| [cache](https://github.com/gofiber/fiber/tree/master/middleware/cache)                 | Reponseları durdur ve önbelleğe al.                                                                                                                                                     |
+| [cache](https://github.com/gofiber/fiber/tree/master/middleware/cache)                 | Reponseları durdur ve önbelleğe al.                                                                                                                                                    |
 | [compress](https://github.com/gofiber/fiber/tree/master/middleware/compress)           | Fiber için sıkıştırma middleware, varsayılan olarak `deflate`, `gzip` ve `brotli`yi destekler.                                                                                         |
 | [cors](https://github.com/gofiber/fiber/tree/master/middleware/cors)                   | Çeşitli seçeneklerle başlangıçlar arası kaynak paylaşımını \(CORS\) etkinleştirin.                                                                                                     |
 | [csrf](https://github.com/gofiber/fiber/tree/master/middleware/csrf)                   | CSRF exploitlerinden korunun.                                                                                                                                                          |
-| [encryptcookie](https://github.com/gofiber/fiber/tree/master/middleware/encryptcookie) | Encrypt middleware'ı cookie değerlerini şifreler.                                                                                                                                       |
-| [etag](https://github.com/gofiber/fiber/tree/master/middleware/etag)                   | ETag middleware'ı sayfa içeriği değişmediyse bant genişliğini daha verimli kullanmak için tam sayfa içeriğini tekrar göndermez.                         |
-| [expvar](https://github.com/gofiber/fiber/tree/master/middleware/expvar)               | Expvar middleware, HTTP serverinin bazı runtime değişkenlerini JSON formatında sunar.                                                                                        |
+| [encryptcookie](https://github.com/gofiber/fiber/tree/master/middleware/encryptcookie) | Encrypt middleware'ı cookie değerlerini şifreler.                                                                                                                                      |
+| [envvar](https://github.com/gofiber/fiber/tree/master/middleware/envvar)               | Environment değişkenlerini belirtilen ayarlara göre dışarıya açar.                                                                                                                     |
+| [etag](https://github.com/gofiber/fiber/tree/master/middleware/etag)                   | ETag middleware'ı sayfa içeriği değişmediyse bant genişliğini daha verimli kullanmak için tam sayfa içeriğini tekrar göndermez.                                                        |
+| [expvar](https://github.com/gofiber/fiber/tree/master/middleware/expvar)               | Expvar middleware, HTTP serverinin bazı runtime değişkenlerini JSON formatında sunar.                                                                                                  |
 | [favicon](https://github.com/gofiber/fiber/tree/master/middleware/favicon)             | Bir dosya yolu sağlanmışsa, loglardaki favicon'u yoksayar veya bellekten sunar.                                                                                                        |
-| [filesystem](https://github.com/gofiber/fiber/tree/master/middleware/filesystem)       | Fiber için FileSystem middleware, Alireza Salary'e özel teşekkürler.                                                                                                                    |
+| [filesystem](https://github.com/gofiber/fiber/tree/master/middleware/filesystem)       | Fiber için FileSystem middleware, Alireza Salary'e özel teşekkürler.                                                                                                                   |
 | [limiter](https://github.com/gofiber/fiber/tree/master/middleware/limiter)             | Fiber için hız sınırlayıcı middleware'i. Açık API'lere ve/veya parola sıfırlama gibi endpointlere yönelik tekrarlanan istekleri sınırlamak için kullanın.                              |
 | [logger](https://github.com/gofiber/fiber/tree/master/middleware/logger)               | HTTP istek/yanıt logger'ı.                                                                                                                                                             |
-| [monitor](https://github.com/gofiber/fiber/tree/master/middleware/monitor)             | Monitor middleware'ı sunucu metriklerini rapor eder, express-status-monitor'den esinlenildi.                                                                                                     |
-| [pprof](https://github.com/gofiber/fiber/tree/master/middleware/pprof)                 | Matthew Lee'ye özel teşekkürler \(@mthli\).                                                                                                                                             |
-| [proxy](https://github.com/gofiber/fiber/tree/master/middleware/proxy)                 | Birden çok sunucuya proxy istekleri yapmanızı sağlar.                                                                                                                                   |
+| [monitor](https://github.com/gofiber/fiber/tree/master/middleware/monitor)             | Monitor middleware'ı sunucu metriklerini rapor eder, express-status-monitor'den esinlenildi.                                                                                           |
+| [pprof](https://github.com/gofiber/fiber/tree/master/middleware/pprof)                 | Matthew Lee'ye özel teşekkürler \(@mthli\).                                                                                                                                            |
+| [proxy](https://github.com/gofiber/fiber/tree/master/middleware/proxy)                 | Birden çok sunucuya proxy istekleri yapmanızı sağlar.                                                                                                                                  |
 | [recover](https://github.com/gofiber/fiber/tree/master/middleware/recover)             | Recover middleware'i, stack chain'ini herhangi bir yerindeki paniklerden kurtulur ve kontrolü merkezileştirilmiş [ErrorHandler'e](https://docs.gofiber.io/guide/error-handling) verir. |
-| [requestid](https://github.com/gofiber/fiber/tree/master/middleware/requestid)         | Her requeste id verir.                                                                                                                                                                  |
-| [session](https://github.com/gofiber/fiber/tree/master/middleware/session)             | Session için middleware. NOTE: Bu middleware Fiber'in Storage yapısını kullanır.                                                                                                                    |
-| [skip](https://github.com/gofiber/fiber/tree/master/middleware/skip)                   | Skip middleware'ı verilen koşul `true` olduğunda handler'ı atlar ve işlemez.                                                                                                                   |
+| [requestid](https://github.com/gofiber/fiber/tree/master/middleware/requestid)         | Her requeste id verir.                                                                                                                                                                 |
+| [session](https://github.com/gofiber/fiber/tree/master/middleware/session)             | Session için middleware. NOTE: Bu middleware Fiber'in Storage yapısını kullanır.                                                                                                       |
+| [skip](https://github.com/gofiber/fiber/tree/master/middleware/skip)                   | Skip middleware'ı verilen koşul `true` olduğunda handler'ı atlar ve işlemez.                                                                                                           |
 | [timeout](https://github.com/gofiber/fiber/tree/master/middleware/timeout)             | Bir request için maksimum süre ekler ve aşılırsa ErrorHandler'a iletir.                                                                                                                |
 
 ## 🧬 Harici Middlewarelar
diff --git a/.github/README_zh-CN.md b/.github/README_zh-CN.md
index 5369548a..b78811e8 100644
--- a/.github/README_zh-CN.md
+++ b/.github/README_zh-CN.md
@@ -573,6 +573,7 @@ func main() {
 | [cors](https://github.com/gofiber/fiber/tree/master/middleware/cors)             | 使用各种选项启用跨源资源共享\(CORS\).                                                                                                          |
 | [csrf](https://github.com/gofiber/fiber/tree/master/middleware/csrf)             | 保护来自CSRF的漏洞.                                                                                                                                                  |
 | [encryptcookie](https://github.com/gofiber/fiber/tree/master/middleware/encryptcookie) | 加密 cookie 值的加密中间件.                                                                                                                             |
+| [envvar](https://github.com/gofiber/fiber/tree/master/middleware/envvar)               | 通过提供可选配置来公开环境变量。.                                                                                                              |
 | [etag](https://github.com/gofiber/fiber/tree/master/middleware/etag)                   | 让缓存更加高效并且节省带宽,让web服务不再需要重新响应整个响应体如果响应内容未变更.               |
 | [expvar](https://github.com/gofiber/fiber/tree/master/middleware/expvar)               | 通过其HTTP服务器运行时间提供JSON格式的暴露变体.                                                                               |
 | [favicon](https://github.com/gofiber/fiber/tree/master/middleware/favicon)       | 如果提供了文件路径，则忽略日志中的图标或从内存中服务.                                                                                                    |
diff --git a/.github/README_zh-TW.md b/.github/README_zh-TW.md
index 1d3907cb..a7f2dfe8 100644
--- a/.github/README_zh-TW.md
+++ b/.github/README_zh-TW.md
@@ -573,6 +573,7 @@ func main() {
 | [cors](https://github.com/gofiber/fiber/tree/master/middleware/cors)             | 使用各種選項啟用跨域資源共享 \(CORS\)。                                                                                  |
 | [csrf](https://github.com/gofiber/fiber/tree/master/middleware/csrf)             | 防止 CSRF 漏洞利用。                                                                                                                          |
 | [encryptcookie](https://github.com/gofiber/fiber/tree/master/middleware/encryptcookie) | Encrypt middleware which encrypts cookie values.                                                                                                                             |
+| [envvar](https://github.com/gofiber/fiber/tree/master/middleware/envvar)               | Expose environment variables with providing an optional config.                                                                                                              |
 | [etag](https://github.com/gofiber/fiber/tree/master/middleware/etag)                   | ETag middleware that lets caches be more efficient and save bandwidth, as a web server does not need to resend a full response if the content has not changed.               |
 | [expvar](https://github.com/gofiber/fiber/tree/master/middleware/expvar)               | Expvar middleware that serves via its HTTP server runtime exposed variants in the JSON format.                                                                               |
 | [favicon](https://github.com/gofiber/fiber/tree/master/middleware/favicon)       | 如果提供了文件路徑，則忽略日誌中的網站圖標或從內存中提供服務。                                                                                                    |
diff --git a/internal/gopsutil/common/common_linux.go b/internal/gopsutil/common/common_linux.go
index 9234f767..a89c8e28 100644
--- a/internal/gopsutil/common/common_linux.go
+++ b/internal/gopsutil/common/common_linux.go
@@ -6,6 +6,7 @@ package common
 import (
 	"context"
 	"fmt"
+	"log"
 	"os"
 	"os/exec"
 	"path/filepath"
@@ -37,7 +38,12 @@ func NumProcs() (uint64, error) {
 	if err != nil {
 		return 0, err
 	}
-	defer f.Close()
+	defer func(f *os.File) {
+		err := f.Close()
+		if err != nil {
+			log.Fatalln(err)
+		}
+	}(f)
 
 	list, err := f.Readdirnames(-1)
 	if err != nil {
diff --git a/middleware/csrf/README.md b/middleware/csrf/README.md
index 8ab8171c..ac574288 100644
--- a/middleware/csrf/README.md
+++ b/middleware/csrf/README.md
@@ -49,9 +49,12 @@ app.Use(csrf.New(csrf.Config{
 	CookieSameSite: "Lax",
 	Expiration:     1 * time.Hour,
 	KeyGenerator:   utils.UUID,
+	Extractor:      func(c *fiber.Ctx) (string, error) { ... },
 }))
 ```
 
+Note: KeyLookup will be ignored if Extractor is explicitly set.
+
 ### Custom Storage/Database
 
 You can use any storage from our [storage](https://github.com/gofiber/storage/) package.
@@ -74,7 +77,7 @@ type Config struct {
 	Next func(c *fiber.Ctx) bool
 
 	// KeyLookup is a string in the form of "<source>:<key>" that is used
-	// to extract token from the request.
+	// to create an Extractor that extracts the token from the request.
 	// Possible values:
 	// - "header:<name>"
 	// - "query:<name>"
@@ -82,6 +85,8 @@ type Config struct {
 	// - "form:<name>"
 	// - "cookie:<name>"
 	//
+	// Ignored if an Extractor is explicitly set.
+	//
 	// Optional. Default: "header:X-CSRF-Token"
 	KeyLookup string
 
@@ -133,6 +138,13 @@ type Config struct {
 	//
 	// Optional. Default: utils.UUID
 	KeyGenerator func() string
+
+	// Extractor returns the csrf token
+	//
+	// If set this will be used in place of an Extractor based on KeyLookup.
+	//
+	// Optional. Default will create an Extractor based on KeyLookup.
+	Extractor func(c *fiber.Ctx) (string, error)
 }
 ```
 
diff --git a/middleware/csrf/config.go b/middleware/csrf/config.go
index 4d9cd7b8..5e45c7b8 100644
--- a/middleware/csrf/config.go
+++ b/middleware/csrf/config.go
@@ -18,7 +18,7 @@ type Config struct {
 	Next func(c *fiber.Ctx) bool
 
 	// KeyLookup is a string in the form of "<source>:<key>" that is used
-	// to extract token from the request.
+	// to create an Extractor that extracts the token from the request.
 	// Possible values:
 	// - "header:<name>"
 	// - "query:<name>"
@@ -26,6 +26,8 @@ type Config struct {
 	// - "form:<name>"
 	// - "cookie:<name>"
 	//
+	// Ignored if an Extractor is explicitly set.
+	//
 	// Optional. Default: "header:X-CSRF-Token"
 	KeyLookup string
 
@@ -92,8 +94,12 @@ type Config struct {
 	// Optional. Default: DefaultErrorHandler
 	ErrorHandler fiber.ErrorHandler
 
-	// extractor returns the csrf token from the request based on KeyLookup
-	extractor func(c *fiber.Ctx) (string, error)
+	// Extractor returns the csrf token
+	//
+	// If set this will be used in place of an Extractor based on KeyLookup.
+	//
+	// Optional. Default will create an Extractor based on KeyLookup.
+	Extractor func(c *fiber.Ctx) (string, error)
 }
 
 // ConfigDefault is the default config
@@ -104,7 +110,7 @@ var ConfigDefault = Config{
 	Expiration:     1 * time.Hour,
 	KeyGenerator:   utils.UUID,
 	ErrorHandler:   defaultErrorHandler,
-	extractor:      csrfFromHeader("X-Csrf-Token"),
+	Extractor:      CsrfFromHeader("X-Csrf-Token"),
 }
 
 // default ErrorHandler that process return error from fiber.Handler
@@ -174,18 +180,20 @@ func configDefault(config ...Config) Config {
 		panic("[CSRF] KeyLookup must in the form of <source>:<key>")
 	}
 
-	// By default we extract from a header
-	cfg.extractor = csrfFromHeader(textproto.CanonicalMIMEHeaderKey(selectors[1]))
-
-	switch selectors[0] {
-	case "form":
-		cfg.extractor = csrfFromForm(selectors[1])
-	case "query":
-		cfg.extractor = csrfFromQuery(selectors[1])
-	case "param":
-		cfg.extractor = csrfFromParam(selectors[1])
-	case "cookie":
-		cfg.extractor = csrfFromCookie(selectors[1])
+	if cfg.Extractor == nil {
+		// By default we extract from a header
+		cfg.Extractor = CsrfFromHeader(textproto.CanonicalMIMEHeaderKey(selectors[1]))
+
+		switch selectors[0] {
+		case "form":
+			cfg.Extractor = CsrfFromForm(selectors[1])
+		case "query":
+			cfg.Extractor = CsrfFromQuery(selectors[1])
+		case "param":
+			cfg.Extractor = CsrfFromParam(selectors[1])
+		case "cookie":
+			cfg.Extractor = CsrfFromCookie(selectors[1])
+		}
 	}
 
 	return cfg
diff --git a/middleware/csrf/csrf.go b/middleware/csrf/csrf.go
index 1de2aec5..e7ad4f2a 100644
--- a/middleware/csrf/csrf.go
+++ b/middleware/csrf/csrf.go
@@ -39,7 +39,7 @@ func New(config ...Config) fiber.Handler {
 			// Assume that anything not defined as 'safe' by RFC7231 needs protection
 
 			// Extract token from client request i.e. header, query, param, form or cookie
-			token, err = cfg.extractor(c)
+			token, err = cfg.Extractor(c)
 			if err != nil {
 				return cfg.ErrorHandler(c, err)
 			}
diff --git a/middleware/csrf/extractors.go b/middleware/csrf/extractors.go
index 2b577b12..ab669bb4 100644
--- a/middleware/csrf/extractors.go
+++ b/middleware/csrf/extractors.go
@@ -15,7 +15,7 @@ var (
 )
 
 // csrfFromParam returns a function that extracts token from the url param string.
-func csrfFromParam(param string) func(c *fiber.Ctx) (string, error) {
+func CsrfFromParam(param string) func(c *fiber.Ctx) (string, error) {
 	return func(c *fiber.Ctx) (string, error) {
 		token := c.Params(param)
 		if token == "" {
@@ -26,7 +26,7 @@ func csrfFromParam(param string) func(c *fiber.Ctx) (string, error) {
 }
 
 // csrfFromForm returns a function that extracts a token from a multipart-form.
-func csrfFromForm(param string) func(c *fiber.Ctx) (string, error) {
+func CsrfFromForm(param string) func(c *fiber.Ctx) (string, error) {
 	return func(c *fiber.Ctx) (string, error) {
 		token := c.FormValue(param)
 		if token == "" {
@@ -37,7 +37,7 @@ func csrfFromForm(param string) func(c *fiber.Ctx) (string, error) {
 }
 
 // csrfFromCookie returns a function that extracts token from the cookie header.
-func csrfFromCookie(param string) func(c *fiber.Ctx) (string, error) {
+func CsrfFromCookie(param string) func(c *fiber.Ctx) (string, error) {
 	return func(c *fiber.Ctx) (string, error) {
 		token := c.Cookies(param)
 		if token == "" {
@@ -48,7 +48,7 @@ func csrfFromCookie(param string) func(c *fiber.Ctx) (string, error) {
 }
 
 // csrfFromHeader returns a function that extracts token from the request header.
-func csrfFromHeader(param string) func(c *fiber.Ctx) (string, error) {
+func CsrfFromHeader(param string) func(c *fiber.Ctx) (string, error) {
 	return func(c *fiber.Ctx) (string, error) {
 		token := c.Get(param)
 		if token == "" {
@@ -59,7 +59,7 @@ func csrfFromHeader(param string) func(c *fiber.Ctx) (string, error) {
 }
 
 // csrfFromQuery returns a function that extracts token from the query string.
-func csrfFromQuery(param string) func(c *fiber.Ctx) (string, error) {
+func CsrfFromQuery(param string) func(c *fiber.Ctx) (string, error) {
 	return func(c *fiber.Ctx) (string, error) {
 		token := c.Query(param)
 		if token == "" {
diff --git a/middleware/envvar/README.md b/middleware/envvar/README.md
new file mode 100644
index 00000000..ce69522a
--- /dev/null
+++ b/middleware/envvar/README.md
@@ -0,0 +1,83 @@
+# Exposing Environment Variables Middleware
+
+EnvVar middleware for [Fiber](https://github.com/gofiber/fiber) that can be used to expose environment variables with various options.
+
+## Table of Contents
+
+- [Environment Variables (EnvVar) Middleware](#environment-variables-envvar-middleware)
+    - [Table of Contents](#table-of-contents)
+    - [Signatures](#signatures)
+    - [Examples](#examples)
+        - [Default Config](#default-config)
+        - [Custom Config](#custom-config)
+        - [Response](#http-response)
+    - [Config](#config)
+    - [Default Config](#default-config-1)
+
+## Signatures
+
+```go
+func New(config ...Config) fiber.Handler
+```
+
+## Examples
+
+First import the middleware from Fiber,
+
+```go
+import (
+  "github.com/gofiber/fiber/v2"
+  "github.com/gofiber/fiber/v2/middleware/envvar"
+)
+```
+
+Then create a Fiber app with `app := fiber.New()`.
+
+**Note**: You need to provide a path to use envvar middleware.
+
+### Default Config
+
+```go
+app.Use("/expose/envvars", envvar.New())
+```
+
+### Custom Config
+
+```go
+app.Use("/expose/envvars", envvar.New(envvar.Config{
+    ExportVars:  map[string]string{"testKey": "", "testDefaultKey": "testDefaultVal"},
+    ExcludeVars: map[string]string{"excludeKey": ""}}
+}))
+```
+
+### Response
+
+Http response contract:
+```
+{
+  "vars": {
+    "someEnvVariable": "someValue",
+    "anotherEnvVariable": "anotherValue",
+  }
+}
+
+```
+
+## Config
+
+```go
+// Config defines the config for middleware.
+type Config struct {
+    // ExportVars specifies the environment variables that should export
+    ExportVars map[string]string
+    // ExcludeVars specifies the environment variables that should not export
+    ExcludeVars map[string]string
+}
+
+```
+
+## Default Config
+
+```go
+Config{}
+```
diff --git a/middleware/envvar/envvar.go b/middleware/envvar/envvar.go
new file mode 100644
index 00000000..373eac50
--- /dev/null
+++ b/middleware/envvar/envvar.go
@@ -0,0 +1,73 @@
+package envvar
+
+import (
+	"github.com/gofiber/fiber/v2"
+	"github.com/gofiber/fiber/v2/utils"
+	"os"
+	"strings"
+)
+
+// Config defines the config for middleware.
+type Config struct {
+	// ExportVars specifies the environment variables that should export
+	ExportVars map[string]string
+	// ExcludeVars specifies the environment variables that should not export
+	ExcludeVars map[string]string
+}
+
+type EnvVar struct {
+	Vars map[string]string `json:"vars"`
+}
+
+func (envVar *EnvVar) set(key, val string) {
+	envVar.Vars[key] = val
+}
+
+var defaultConfig = Config{}
+
+func New(config ...Config) fiber.Handler {
+	var cfg = defaultConfig
+	if len(config) > 0 {
+		cfg = config[0]
+	}
+
+	return func(c *fiber.Ctx) error {
+		if c.Method() != fiber.MethodGet {
+			return fiber.ErrMethodNotAllowed
+		}
+
+		envVar := newEnvVar(cfg)
+		varsByte, err := c.App().Config().JSONEncoder(envVar)
+		if err != nil {
+			c.Response().SetBodyRaw(utils.UnsafeBytes(err.Error()))
+			c.Response().SetStatusCode(fiber.StatusInternalServerError)
+			return nil
+		}
+		c.Response().SetBodyRaw(varsByte)
+		c.Response().SetStatusCode(fiber.StatusOK)
+		c.Response().Header.Set("Content-Type", "application/json; charset=utf-8")
+		return nil
+	}
+}
+
+func newEnvVar(cfg Config) *EnvVar {
+	vars := &EnvVar{Vars: make(map[string]string)}
+
+	if len(cfg.ExportVars) > 0 {
+		for key, defaultVal := range cfg.ExportVars {
+			vars.set(key, defaultVal)
+			if envVal, exists := os.LookupEnv(key); exists {
+				vars.set(key, envVal)
+			}
+		}
+	} else {
+		for _, envVal := range os.Environ() {
+			keyVal := strings.Split(envVal, "=")
+			if _, exists := cfg.ExcludeVars[keyVal[0]]; !exists {
+				vars.set(keyVal[0], keyVal[1])
+			}
+		}
+	}
+
+	return vars
+}


Test patch:
diff --git a/helpers_test.go b/helpers_test.go
index 7b45540d..f1bfbb2e 100644
--- a/helpers_test.go
+++ b/helpers_test.go
@@ -22,7 +22,8 @@ func Test_Utils_ETag(t *testing.T) {
 	t.Run("Not Status OK", func(t *testing.T) {
 		c := app.AcquireCtx(&fasthttp.RequestCtx{})
 		defer app.ReleaseCtx(c)
-		c.SendString("Hello, World!")
+		err := c.SendString("Hello, World!")
+		utils.AssertEqual(t, nil, err)
 		c.Status(201)
 		setETag(c, false)
 		utils.AssertEqual(t, "", string(c.Response().Header.Peek(HeaderETag)))
@@ -38,7 +39,8 @@ func Test_Utils_ETag(t *testing.T) {
 	t.Run("Has HeaderIfNoneMatch", func(t *testing.T) {
 		c := app.AcquireCtx(&fasthttp.RequestCtx{})
 		defer app.ReleaseCtx(c)
-		c.SendString("Hello, World!")
+		err := c.SendString("Hello, World!")
+		utils.AssertEqual(t, nil, err)
 		c.Request().Header.Set(HeaderIfNoneMatch, `"13-1831710635"`)
 		setETag(c, false)
 		utils.AssertEqual(t, 304, c.Response().StatusCode())
@@ -49,7 +51,8 @@ func Test_Utils_ETag(t *testing.T) {
 	t.Run("No HeaderIfNoneMatch", func(t *testing.T) {
 		c := app.AcquireCtx(&fasthttp.RequestCtx{})
 		defer app.ReleaseCtx(c)
-		c.SendString("Hello, World!")
+		err := c.SendString("Hello, World!")
+		utils.AssertEqual(t, nil, err)
 		setETag(c, false)
 		utils.AssertEqual(t, `"13-1831710635"`, string(c.Response().Header.Peek(HeaderETag)))
 	})
@@ -60,7 +63,8 @@ func Benchmark_Utils_ETag(b *testing.B) {
 	app := New()
 	c := app.AcquireCtx(&fasthttp.RequestCtx{})
 	defer app.ReleaseCtx(c)
-	c.SendString("Hello, World!")
+	err := c.SendString("Hello, World!")
+	utils.AssertEqual(b, nil, err)
 	for n := 0; n < b.N; n++ {
 		setETag(c, false)
 	}
@@ -73,7 +77,8 @@ func Test_Utils_ETag_Weak(t *testing.T) {
 	t.Run("Set Weak", func(t *testing.T) {
 		c := app.AcquireCtx(&fasthttp.RequestCtx{})
 		defer app.ReleaseCtx(c)
-		c.SendString("Hello, World!")
+		err := c.SendString("Hello, World!")
+		utils.AssertEqual(t, nil, err)
 		setETag(c, true)
 		utils.AssertEqual(t, `W/"13-1831710635"`, string(c.Response().Header.Peek(HeaderETag)))
 	})
diff --git a/middleware/csrf/csrf_test.go b/middleware/csrf/csrf_test.go
index 082b3519..90650bf3 100644
--- a/middleware/csrf/csrf_test.go
+++ b/middleware/csrf/csrf_test.go
@@ -236,6 +236,50 @@ func Test_CSRF_From_Cookie(t *testing.T) {
 	utils.AssertEqual(t, "OK", string(ctx.Response.Body()))
 }
 
+func Test_CSRF_From_Custom(t *testing.T) {
+	app := fiber.New()
+
+	extractor := func(c *fiber.Ctx) (string, error) {
+		body := string(c.Body())
+		// Generate the correct extractor to get the token from the correct location
+		selectors := strings.Split(body, "=")
+
+		if len(selectors) != 2 || selectors[1] == "" {
+			return "", errMissingParam
+		}
+		return selectors[1], nil
+	}
+
+	app.Use(New(Config{Extractor: extractor}))
+
+	app.Post("/", func(c *fiber.Ctx) error {
+		return c.SendStatus(fiber.StatusOK)
+	})
+
+	h := app.Handler()
+	ctx := &fasthttp.RequestCtx{}
+
+	// Invalid CSRF token
+	ctx.Request.Header.SetMethod("POST")
+	ctx.Request.Header.Set(fiber.HeaderContentType, fiber.MIMETextPlain)
+	h(ctx)
+	utils.AssertEqual(t, 403, ctx.Response.StatusCode())
+
+	// Generate CSRF token
+	ctx.Request.Reset()
+	ctx.Response.Reset()
+	ctx.Request.Header.SetMethod("GET")
+	h(ctx)
+	token := string(ctx.Response.Header.Peek(fiber.HeaderSetCookie))
+	token = strings.Split(strings.Split(token, ";")[0], "=")[1]
+
+	ctx.Request.Header.SetMethod("POST")
+	ctx.Request.Header.Set(fiber.HeaderContentType, fiber.MIMETextPlain)
+	ctx.Request.SetBodyString("_csrf=" + token)
+	h(ctx)
+	utils.AssertEqual(t, 200, ctx.Response.StatusCode())
+}
+
 func Test_CSRF_ErrorHandler_InvalidToken(t *testing.T) {
 	app := fiber.New()
 
diff --git a/middleware/envvar/envvar_test.go b/middleware/envvar/envvar_test.go
new file mode 100644
index 00000000..edb74d5f
--- /dev/null
+++ b/middleware/envvar/envvar_test.go
@@ -0,0 +1,104 @@
+package envvar
+
+import (
+	"encoding/json"
+	"github.com/gofiber/fiber/v2"
+	"github.com/gofiber/fiber/v2/utils"
+	"io/ioutil"
+	"net/http"
+	"os"
+	"testing"
+)
+
+func TestEnvVarStructWithExportVarsExcludeVars(t *testing.T) {
+	os.Setenv("testKey", "testEnvValue")
+	os.Setenv("anotherEnvKey", "anotherEnvVal")
+	os.Setenv("excludeKey", "excludeEnvValue")
+	defer os.Unsetenv("testKey")
+	defer os.Unsetenv("anotherEnvKey")
+	defer os.Unsetenv("excludeKey")
+
+	vars := newEnvVar(Config{
+		ExportVars:  map[string]string{"testKey": "", "testDefaultKey": "testDefaultVal"},
+		ExcludeVars: map[string]string{"excludeKey": ""}})
+
+	utils.AssertEqual(t, vars.Vars["testKey"], "testEnvValue")
+	utils.AssertEqual(t, vars.Vars["testDefaultKey"], "testDefaultVal")
+	utils.AssertEqual(t, vars.Vars["excludeKey"], "")
+	utils.AssertEqual(t, vars.Vars["anotherEnvKey"], "")
+}
+
+func TestEnvVarHandler(t *testing.T) {
+	os.Setenv("testKey", "testVal")
+	defer os.Unsetenv("testKey")
+
+	expectedEnvVarResponse, _ := json.Marshal(
+		struct {
+			Vars map[string]string `json:"vars"`
+		}{
+			map[string]string{"testKey": "testVal"},
+		})
+
+	app := fiber.New()
+	app.Use("/envvars", New(Config{
+		ExportVars: map[string]string{"testKey": ""}}))
+
+	req, _ := http.NewRequest("GET", "http://localhost/envvars", nil)
+	resp, err := app.Test(req)
+	utils.AssertEqual(t, nil, err)
+
+	respBody, err := ioutil.ReadAll(resp.Body)
+	utils.AssertEqual(t, nil, err)
+
+	utils.AssertEqual(t, expectedEnvVarResponse, respBody)
+}
+
+func TestEnvVarHandlerNotMatched(t *testing.T) {
+	app := fiber.New()
+	app.Use("/envvars", New(Config{
+		ExportVars: map[string]string{"testKey": ""}}))
+
+	app.Get("/another-path", func(ctx *fiber.Ctx) error {
+		ctx.SendString("OK")
+		return nil
+	})
+
+	req, _ := http.NewRequest("GET", "http://localhost/another-path", nil)
+	resp, err := app.Test(req)
+	utils.AssertEqual(t, nil, err)
+
+	respBody, err := ioutil.ReadAll(resp.Body)
+	utils.AssertEqual(t, nil, err)
+
+	utils.AssertEqual(t, []byte("OK"), respBody)
+}
+
+func TestEnvVarHandlerDefaultConfig(t *testing.T) {
+	os.Setenv("testEnvKey", "testEnvVal")
+	defer os.Unsetenv("testEnvKey")
+
+	app := fiber.New()
+	app.Use("/envvars", New())
+
+	req, _ := http.NewRequest("GET", "http://localhost/envvars", nil)
+	resp, err := app.Test(req)
+	utils.AssertEqual(t, nil, err)
+
+	respBody, err := ioutil.ReadAll(resp.Body)
+	utils.AssertEqual(t, nil, err)
+
+	var envVars EnvVar
+	utils.AssertEqual(t, nil, json.Unmarshal(respBody, &envVars))
+	val := envVars.Vars["testEnvKey"]
+	utils.AssertEqual(t, "testEnvVal", val)
+}
+
+func TestEnvVarHandlerMethod(t *testing.T) {
+	app := fiber.New()
+	app.Use("/envvars", New())
+
+	req, _ := http.NewRequest("POST", "http://localhost/envvars", nil)
+	resp, err := app.Test(req)
+	utils.AssertEqual(t, nil, err)
+	utils.AssertEqual(t, fiber.StatusMethodNotAllowed, resp.StatusCode)
+}