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
Is your feature request related to a problem? Please describe.
In Salvo, you have to imperatively call the depot.get() / depot.obtain() method to extract state from the depot, instead of being able to put it in the parameters.
Parameter state extraction makes for handlers that are easier to unit test and are somewhat less coupled to the specific framework, and do so without resorting to true global state.
Describe the solution you'd like
Axum and similar rust HTTP frameworks have State which works similarly to Depot in Salvo, except that you can do this:
asyncfnposts_handler(State(state):State<AppState>){// use `state`...}
instead of salvo like:
asyncfnposts_handler(depot:&mutDepot){let state = depot.obtain::<AppState>().unwrap();// use `state`...}
It would be great if Salvo could do similar parameter-level unwrapping with obtain, so we could write something like:
asyncfnposts_handler(Depot(state):Depot<AppState>){// use `state`...}
Describe alternatives you've considered
N/A
Additional context
N/A
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
In Salvo, you have to imperatively call the
depot.get()
/depot.obtain()
method to extract state from the depot, instead of being able to put it in the parameters.Parameter state extraction makes for handlers that are easier to unit test and are somewhat less coupled to the specific framework, and do so without resorting to true global state.
Describe the solution you'd like
Axum and similar rust HTTP frameworks have State which works similarly to Depot in Salvo, except that you can do this:
instead of salvo like:
It would be great if Salvo could do similar parameter-level unwrapping with
obtain
, so we could write something like:Describe alternatives you've considered
N/A
Additional context
N/A
The text was updated successfully, but these errors were encountered: