diff --git a/middleware/requestid/requestid.go b/middleware/requestid/requestid.go index 9b5e38db65..ef67e6f21c 100644 --- a/middleware/requestid/requestid.go +++ b/middleware/requestid/requestid.go @@ -50,6 +50,9 @@ func New(config ...Config) fiber.Handler { // FromContext returns the request ID from context. // If there is no request ID, an empty string is returned. +// Supported context types: +// - fiber.Ctx: Retrieves request ID from Locals +// - context.Context: Retrieves request ID from context values func FromContext(c any) string { switch ctx := c.(type) { case fiber.Ctx: @@ -61,7 +64,7 @@ func FromContext(c any) string { return rid } default: - log.Errorf("Unsupported context type: %T", c) + log.Errorf("Unsupported context type: %T. Expected fiber.Ctx or context.Context", c) } return "" } diff --git a/middleware/requestid/requestid_test.go b/middleware/requestid/requestid_test.go index 300c8ecbf8..ad36884aca 100644 --- a/middleware/requestid/requestid_test.go +++ b/middleware/requestid/requestid_test.go @@ -62,8 +62,8 @@ func Test_RequestID_FromContext(t *testing.T) { } tests := []struct { - name string args args + name string }{ { name: "From fiber.Ctx", @@ -84,7 +84,6 @@ func Test_RequestID_FromContext(t *testing.T) { } for _, tt := range tests { - tt := tt // Re bind variables t.Run(tt.name, func(t *testing.T) { t.Parallel()