]> piware.de Git - learn-rust.git/commitdiff
axum-server: Sync directory route and port with warp-server
authorMartin Pitt <martin@piware.de>
Fri, 9 Dec 2022 11:05:11 +0000 (12:05 +0100)
committerMartin Pitt <martin@piware.de>
Fri, 9 Dec 2022 11:05:11 +0000 (12:05 +0100)
axum-server/src/main.rs

index 02b4700d1e5352348e59d204b7e94f8332d64365..2a2eaaab2f63339bbd80235ecf29337af63503e6 100644 (file)
@@ -47,8 +47,8 @@ async fn main() {
     tracing_subscriber::fmt::init();
     let app = Router::new()
         .route("/hello/:name", get(hello))
-        .nest("/static",
-               get_service(tower_http::services::ServeDir::new(".").precompressed_gzip())
+        .nest("/dir",
+               get_service(tower_http::services::ServeDir::new("../static").precompressed_gzip())
                    .handle_error(|e: io::Error| async move {
                        (StatusCode::INTERNAL_SERVER_ERROR, format!("Unhandled internal error: {}", e))
                    })
@@ -62,7 +62,7 @@ async fn main() {
                 )
         );
 
-    let addr = std::net::SocketAddr::from(([127, 0, 0, 1], 3000));
+    let addr = std::net::SocketAddr::from(([127, 0, 0, 1], 3030));
     tracing::info!("listening on {}", addr);
     axum::Server::bind(&addr)
         .serve(app.into_make_service())