Open Pistonight opened 11 months ago
tower-http v0.4.4
All
When using ServeDir::try_call to request a path that does not exist, it returns Ok(404) instead of an Err
ServeDir::try_call
Ok(404)
Err
use axum::http::Request; use tower_http::services::ServeDir; use tracing::{error, info}; #[tokio::main] async fn main() { tracing_subscriber::fmt::init(); let mut serve_dir = ServeDir::new("src"); let mut req = Request::new(()); *req.uri_mut() = "/main.rs".parse().unwrap(); match serve_dir.try_call(req).await { Ok(response) => info!("response code: {}", response.status()), Err(e) => error!("error: {}", e), } let mut req2 = Request::new(()); *req2.uri_mut() = "/doesnotexist.rs".parse().unwrap(); match serve_dir.try_call(req2).await { Ok(response) => info!("response code: {}", response.status()), Err(e) => error!("error: {}", e), } }
Expected:
2023-09-23T18:09:09.141584Z INFO rs_playground: response code: 200 OK 2023-09-23T18:09:09.141801Z ERROR rs_playground: error: <something>
Actual:
2023-09-23T18:09:09.141584Z INFO rs_playground: response code: 200 OK 2023-09-23T18:09:09.141801Z INFO rs_playground: response code: 404 Not Found
I think a PR to fix this would be welcome (cc @davidpdrsn).
Bug Report
Version
tower-http v0.4.4
Platform
All
Description
When using
ServeDir::try_call
to request a path that does not exist, it returnsOk(404)
instead of anErr
Expected:
Actual: