Replies: 1 comment 2 replies
-
|
Can you show a real-world example? If you have a request type that's only meant to support a single route and uses |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Sometimes it makes sense to have a type that implements
FromRequestand can be used to parse the whole request body. This is especially convenient with#[derive(FromRequest)]and#[from_request(via)].For a request type like this it also makes a lot of sense for the handler function to be a method, callable as
request.handle(...).This currently doesn't work in the general case.
I believe one of the reasons Axum is loved this much is that it's not very frameworky. This is one of the few places where it creates and demands that users follow special Axum idioms instead of general Rust idioms.
In practice, I see two main obstacles:
selfmust be the first argument butFromRequestmust be the last argument. This can be fixed cleanly by makingFromRequesttreat the first argument as special, but this would be a big breaking change of course.#[axum::debug_handle]interpretsselfas module name.A breaking change like this would be annoying and would certainly require some kind of automated rewriting. But feels definitely worth it in the long term?
Beta Was this translation helpful? Give feedback.
All reactions