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
Linux host 5.18.7-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 25 Jun 2022 20:22:01 +0000 x86_64 GNU/Linux
Description
I would expect the order in which I define the parameters not to matter. If I extract Request<Body> before any Extension<..> it will just not find them at runtime, see example. But if I just define the Extension<..> first it works as expected. I don't know if there is the same issue for other extractors. But at least for the Query<..> it doesn't matter if it is before or after the Request<Body>.
Example:
use axum::{routing::get,Extension,Router, http::Request, body::Body};use std::{
net::SocketAddr,
sync::Arc,};structState;asyncfngood(_state:Extension<Arc<State>>,_req:Request<Body>){}asyncfnbad(_req:Request<Body>,_state:Extension<Arc<State>>){}#[tokio::main]asyncfnmain(){let state = Arc::new(State);let app = Router::new().route("/good",get(good)).route("/bad",get(bad)).layer(Extension(state));let addr = SocketAddr::from(([127,0,0,1],3000));
axum::Server::bind(&addr).serve(app.into_make_service()).await.unwrap();}
$ curl localhost:3000/good
$ curl localhost:3000/bad
Missing request extension: Extension of type `alloc::sync::Arc<minimal::State>` was not found. Perhaps you forgot to add it? See `axum::Extension`.
The text was updated successfully, but these errors were encountered:
Ah so it is documented, I guess my bad for not finding it. Would have expected to find a note of it here: https://docs.rs/axum/latest/axum/struct.Extension.html
But adding it now isn't really necessary if it will be fixed soon, and it should be hopefully easy enough to find through github issues now, I guess.
Thanks for the reply tho!
Bug Report
Version
├── axum v0.5.10 (https://github.com/tokio-rs/axum.git#329bd5f9)
│ ├── axum-core v0.2.6 (https://github.com/tokio-rs/axum.git#329bd5f9)
and
├── axum v0.5.13
│ ├── axum-core v0.2.7
Platform
Linux host 5.18.7-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 25 Jun 2022 20:22:01 +0000 x86_64 GNU/Linux
Description
I would expect the order in which I define the parameters not to matter. If I extract
Request<Body>
before anyExtension<..>
it will just not find them at runtime, see example. But if I just define theExtension<..>
first it works as expected. I don't know if there is the same issue for other extractors. But at least for theQuery<..>
it doesn't matter if it is before or after theRequest<Body>
.Example:
The text was updated successfully, but these errors were encountered: