Skip to content

Commit

Permalink
fix: Modify structure sorting to reduce memory usage
Browse files Browse the repository at this point in the history
  • Loading branch information
JIeJaitt committed Nov 15, 2024
1 parent 0e31b2f commit 869beb2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 4 additions & 1 deletion middleware/requestid/requestid.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 ""
}
3 changes: 1 addition & 2 deletions middleware/requestid/requestid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ func Test_RequestID_FromContext(t *testing.T) {
}

tests := []struct {
name string
args args
name string
}{
{
name: "From fiber.Ctx",
Expand All @@ -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()

Expand Down

0 comments on commit 869beb2

Please sign in to comment.