diff --git a/examples/global-404-handler/src/main.rs b/examples/global-404-handler/src/main.rs index 16783b2f..c5c316f4 100644 --- a/examples/global-404-handler/src/main.rs +++ b/examples/global-404-handler/src/main.rs @@ -5,14 +5,11 @@ //! ``` use axum::{ - body::{box_body, Body, BoxBody}, - handler::get, - http::{Response, StatusCode}, + handler::{get, Handler}, response::Html, Router, }; use std::net::SocketAddr; -use tower::util::MapResponseLayer; #[tokio::main] async fn main() { @@ -23,10 +20,10 @@ async fn main() { tracing_subscriber::fmt::init(); // build our application with a route - let app = Router::new() - .route("/", get(handler)) - // make sure this is added as the very last thing - .layer(MapResponseLayer::new(map_404)); + let app = Router::new().route("/", get(handler)); + + // make sure this is added as the very last thing + let app = app.or(handler_404.into_service()); // run it let addr = SocketAddr::from(([127, 0, 0, 1], 3000)); @@ -41,15 +38,6 @@ async fn handler() -> Html<&'static str> { Html("