We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If the extract::* types like Json would implement std::ops::Deref you could write
extract::*
Json
std::ops::Deref
#[derive(Deserialize, Serialize)] struct Request { foo: u8, } async fn handler(req: Json<Request>) { println!("{}", req.foo); }
instead of
async fn handler(Json(req): Json<Request>) { println!("{}", req.foo); }
or
async fn handler(req: Json<Request>) { let req = req.0; println!("{}", req.foo); }
which IMO is easier to read.
The disadvantage is that it introduces some "Magic" that might be difficult to understand for newer rust developers.
The bevy game engine can write ECS systems similar to how axum's request handlers work (example) and there you can write e.g.
axum
fn system(resource: Res<Foo>) { println!("{}", resource.foo); }
which works really well and leads to very readably systems.
The text was updated successfully, but these errors were encountered:
Implement Deref for extractors
Deref
f1b7df5
Fixes #54
Implement Deref for extractors (#56)
5407247
Successfully merging a pull request may close this issue.
If the
extract::*
types likeJson
would implementstd::ops::Deref
you could writeinstead of
or
which IMO is easier to read.
The disadvantage is that it introduces some "Magic" that might be difficult to understand for newer rust developers.
Prior art
The bevy game engine can write ECS systems similar to how
axum
's request handlers work (example) and there you can write e.g.which works really well and leads to very readably systems.
The text was updated successfully, but these errors were encountered: