fiber/docs/api/middleware
Benjamin Grosse b1850834a3
fix: don't constrain middlewares' context-keys to strings 🐛 (#2751)
* Revert "Revert "🐛 requestid.Config.ContextKey is interface{} (#2369)" (#2742)"

This reverts commit 28be17f929.

* fix: request ContextKey default value condition

Should check for `nil` since it is `any`.

* fix: don't constrain middlewares' context-keys to strings

`context` recommends using "unexported type" as context keys to avoid
collisions https://pkg.go.dev/github.com/gofiber/fiber/v2#Ctx.Locals.

The official go blog also recommends this https://go.dev/blog/context.

`fiber.Ctx.Locals(key any, value any)` correctly allows consumers to
use unexported types or e.g. strings.

But some fiber middlewares constrain their context-keys to `string` in
their "default config structs", making it impossible to use unexported
types.

This PR removes the `string` _constraint_ from all middlewares, allowing
to now use unexported types as per the official guidelines. However
the default value is still a string, so it's not a breaking change, and
anyone still using strings as context keys is not affected.
2023-12-12 14:55:29 +01:00
..
_category_.json 📝 docs: automated synchronization with `gofiber/docs` (#2344) 2023-02-25 10:29:07 +01:00
adaptor.md improved the config section of the middleware readme´s (#2552) 2023-07-24 16:46:50 +02:00
basicauth.md fix: don't constrain middlewares' context-keys to strings 🐛 (#2751) 2023-12-12 14:55:29 +01:00
cache.md Update cache.md 2023-09-20 09:14:58 +02:00
compress.md improve compress middleware documentation 2023-10-05 09:00:11 +02:00
cors.md 📝 middleware: cors: update docs to better explain AllowOriginsFunc (#2652) 2023-09-28 08:28:35 +02:00
csrf.md fix: don't constrain middlewares' context-keys to strings 🐛 (#2751) 2023-12-12 14:55:29 +01:00
earlydata.md improved the config section of the middleware readme´s (#2552) 2023-07-24 16:46:50 +02:00
encryptcookie.md chore(encryptcookie)!: update default config (#2753) 2023-12-07 08:39:41 +01:00
envvar.md improved the config section of the middleware readme´s (#2552) 2023-07-24 16:46:50 +02:00
etag.md improved the config section of the middleware readme´s (#2552) 2023-07-24 16:46:50 +02:00
expvar.md improved the config section of the middleware readme´s (#2552) 2023-07-24 16:46:50 +02:00
favicon.md Add custom data property to favicon middleware config (#2579) 2023-08-17 15:04:53 +02:00
filesystem.md improve sendFile documentation 2023-10-06 11:43:10 +02:00
helmet.md improved the config section of the middleware readme´s (#2552) 2023-07-24 16:46:50 +02:00
idempotency.md improved the config section of the middleware readme´s (#2552) 2023-07-24 16:46:50 +02:00
keyauth.md fix: don't constrain middlewares' context-keys to strings 🐛 (#2751) 2023-12-12 14:55:29 +01:00
limiter.md improved the config section of the middleware readme´s (#2552) 2023-07-24 16:46:50 +02:00
logger.md 🩹 middleware/logger/: log client IP address by default (#2755) 2023-12-08 10:36:43 +01:00
monitor.md improved the config section of the middleware readme´s (#2552) 2023-07-24 16:46:50 +02:00
pprof.md improved the config section of the middleware readme´s (#2552) 2023-07-24 16:46:50 +02:00
proxy.md improved the config section of the middleware readme´s 2023-07-24 17:03:11 +02:00
recover.md improved the config section of the middleware readme´s (#2552) 2023-07-24 16:46:50 +02:00
redirect.md improved the config section of the middleware readme´s (#2552) 2023-07-24 16:46:50 +02:00
requestid.md fix: don't constrain middlewares' context-keys to strings 🐛 (#2751) 2023-12-12 14:55:29 +01:00
rewrite.md improved the config section of the middleware readme´s (#2552) 2023-07-24 16:46:50 +02:00
session.md feat: add Reset method to Session struct in session middleware (#2654) 2023-10-02 15:19:35 +02:00
skip.md improved the config section of the middleware readme´s (#2552) 2023-07-24 16:46:50 +02:00
timeout.md improved the config section of the middleware readme´s (#2552) 2023-07-24 16:46:50 +02:00