- Notifications
You must be signed in to change notification settings - Fork 589
Description
Many of the fields of server.Server are callbacks that don't take either an *http.Request
or a context.Context
as arguments. This means it is impossible to use any request-specific information in them: For example, I'd like to log errors with a request ID, increment metrics with request-specific labels (like the path and method) and set a custom verbosity per request.
It would be great if there was a way to set these fields on a per-request basis. The simplest way would be to add a context.Context
field, but that would be backwards-incompatible. Another way would be to add a (for example) CallbacksForRequest(*http.Request) Server
function that could be used to return closures encapsulating all the request-specific data needed. That would be less ergonomical, but work.