From: Martin Pitt Date: Sat, 12 Nov 2022 10:18:04 +0000 (+0100) Subject: axum-server: Serve whole directory X-Git-Url: https://piware.de/gitweb/?a=commitdiff_plain;h=ffdc1bdd9f104219c50c20316dded52e937541fe;p=learn-rust.git axum-server: Serve whole directory --- diff --git a/axum-server/src/main.rs b/axum-server/src/main.rs index 31c0a4f..02b4700 100644 --- a/axum-server/src/main.rs +++ b/axum-server/src/main.rs @@ -47,8 +47,8 @@ async fn main() { tracing_subscriber::fmt::init(); let app = Router::new() .route("/hello/:name", get(hello)) - .route("/static", - get_service(tower_http::services::ServeFile::new("Cargo.toml").precompressed_gzip()) + .nest("/static", + get_service(tower_http::services::ServeDir::new(".").precompressed_gzip()) .handle_error(|e: io::Error| async move { (StatusCode::INTERNAL_SERVER_ERROR, format!("Unhandled internal error: {}", e)) })