If executing multiple calls to requestid.New (in tests for example) the writing to a global var produces a race condition, this can easily be avoided with a simple lock supplementing the global var.
This kinda raised another question for me, what if I want to use the request id middleware for multiple servers in a single app with different header keys?
I honestly think it would best to save the header key in the gin context for that request and later if fetched check in the context what the key is.
If executing multiple calls to
requestid.New(in tests for example) the writing to a global var produces a race condition, this can easily be avoided with a simple lock supplementing the global var.This kinda raised another question for me, what if I want to use the request id middleware for multiple servers in a single app with different header keys?
I honestly think it would best to save the header key in the gin context for that request and later if fetched check in the context what the key is.