fiber/middleware/idempotency
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
..
config.go 🐛 bug: fix nil pointer dereference issue on idempotency middleware (#2668) 2023-10-10 08:23:23 +02:00
idempotency.go fix: don't constrain middlewares' context-keys to strings 🐛 (#2751) 2023-12-12 14:55:29 +01:00
idempotency_test.go 🚀 Feature: Add and apply more stricter golangci-lint linting rules (#2286) 2023-01-27 09:01:37 +01:00
locker.go 🚀 Feature: Add idempotency middleware (v2 backport) (#2288) 2023-01-13 08:38:50 +01:00
locker_test.go 🚀 Feature: Add idempotency middleware (v2 backport) (#2288) 2023-01-13 08:38:50 +01:00
response.go ctx: change signatures of GetReqHeaders and GetRespHeaders (#2650) 2023-09-28 08:31:31 +02:00
response_msgp.go ctx: change signatures of GetReqHeaders and GetRespHeaders (#2650) 2023-09-28 08:31:31 +02:00
response_msgp_test.go 🐛 Bug: Fix issues introduced in linting PR (#2319) 2023-02-02 15:57:40 +01:00