Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(requestid): fix condition for setting default value of ContextKey… #2731

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion middleware/requestid/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func configDefault(config ...Config) Config {
if cfg.Generator == nil {
cfg.Generator = ConfigDefault.Generator
}
if cfg.ContextKey == "" {
if cfg.ContextKey == nil || cfg.ContextKey == "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ContextKey will only ever be "" if the user explicitly sets it to that value. In that case, overriding it to be "requestid" might be surprising.
Though I suppose changing it to accept "" now might break someone's code out there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be fine, check this #2731 (comment)

cfg.ContextKey = ConfigDefault.ContextKey
}
return cfg
Expand Down
Loading