You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can see the use for passing the raw HTTP request. How do you envision this feature? Like modifying every handler signature to pass the raw Request object too? e.g. HandleChannelUpdate func(req *http.Request, h *esb.ResponseHeaders, event *esb.EventChannelUpdate)
Or were you thinking adding some general handler OnRequest(req *http.Request) to the SubHandler? This second case could probably be implemented by wrapping the SubHandler as it implements http.Handler. Going with the first option of adding a function parameter to every handler would be a breaking change, and so if I were to make that I may also redesign some bits of the library that I'm unhappy with.
For your second question:
As for passing the request context (I assume you mean the context returned from r.Context()) to the handler functions, for example HandleChannelUpdate func(ctx context.Context, h *esb.ResponseHeaders, event *esb.EventChannelUpdate), I'm not sure. It feels a bit like an anti-pattern to pass the context of a request that is about to finish to an asynchronous event handler.
However, there is context.Context.WithoutCancel, which could be used to just copy the values in the context detached from the deadline associated with the request. If you just need the key-values in the context, you could probably construct an empty context at the start of the handler, populate it, and pass it on. I'm hesitant about making these handlers take a ton of arguments.
Might be good to get raw http request for own need, for example tracing.
Also might be good to pass ctx from request to handlers
What do you think?
The text was updated successfully, but these errors were encountered: