-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
Description
Bug Description
This is my fix:
- if cfg.ContextKey == "" {
+ if cfg.ContextKey == nil || cfg.ContextKey == "" {
cfg.ContextKey = ConfigDefault.ContextKey
}The fix checks if cfg.ContextKey is either nil or an empty string before assigning the default value ConfigDefault.ContextKey. This ensures that the ContextKey is not missing or empty.
How to Reproduce
package main
import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/requestid"
"github.com/gofiber/fiber/v2/utils"
)
import "log"
func main() {
app := fiber.New()
// Steps to reproduce
app.Use(requestid.New(requestid.Config{
// ContextKey is currently nil
Generator: utils.UUID,
}))
log.Fatal(app.Listen(":3000"))
}
Expected Behavior
...
Fiber Version
v2.51.0
Code Snippet (optional)
No response
Checklist:
- I agree to follow Fiber's Code of Conduct.
- I have checked for existing issues that describe my problem prior to opening this one.
- I understand that improperly formatted bug reports may be closed without explanation.
Reactions are currently unavailable