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
When writing a Service implementation that wraps a MethodRouter, and when the wrapping service's call method needs to do some async work before forwarding the request to MethodRouter, there is no way to avoid cloning the entire MethodRouter (or putting it behind a mutex, which is almost certainly worse). This is because MethodRouter does not expose any way to handle a request without a &mut MethodRouter, and futures returned by Service::call (understandably) cannot capture &mut self.
Proposal
Adding a method to MethodRouter that routes a request with a &MethodRouter would allow the wrapping service to hold an Arc<MethodRouter>. Changing MethodRouter::call_with_state from pub(crate) to pub would resolve this, though whether this is the correct way to resolve this request is likely a question better answered by the axum maintainers.
Alternatives
Any other approach that allows me to route a request using a &MethodRouter would be totally acceptable.
The text was updated successfully, but these errors were encountered:
Feature Request
Motivation
When writing a
Service
implementation that wraps aMethodRouter
, and when the wrapping service'scall
method needs to do some async work before forwarding the request toMethodRouter
, there is no way to avoid cloning the entireMethodRouter
(or putting it behind a mutex, which is almost certainly worse). This is becauseMethodRouter
does not expose any way to handle a request without a&mut MethodRouter
, and futures returned byService::call
(understandably) cannot capture&mut self
.Proposal
Adding a method to
MethodRouter
that routes a request with a&MethodRouter
would allow the wrapping service to hold anArc<MethodRouter>
. ChangingMethodRouter::call_with_state
frompub(crate)
topub
would resolve this, though whether this is the correct way to resolve this request is likely a question better answered by the axum maintainers.Alternatives
Any other approach that allows me to route a request using a
&MethodRouter
would be totally acceptable.The text was updated successfully, but these errors were encountered: