//! Run with //! //! ```not_rust //! cargo run -p example-global-404-handler //! ``` use axum::{ handler::Handler, http::StatusCode, response::{Html, IntoResponse}, routing::get, Router, }; use std::net::SocketAddr; #[tokio::main] async fn main() { // Set the RUST_LOG, if it hasn't been explicitly defined if std::env::var_os("RUST_LOG").is_none() { std::env::set_var("RUST_LOG", "example_global_404_handler=debug") } tracing_subscriber::fmt::init(); // build our application with a route let app = Router::new().route("/", get(handler)); // add a fallback service for handling routes to unknown paths let app = app.fallback(handler_404.into_service()); // run it let addr = SocketAddr::from(([127, 0, 0, 1], 3000)); tracing::debug!("listening on {}", addr); axum::Server::bind(&addr) .serve(app.into_make_service()) .await .unwrap(); } async fn handler() -> Html<&'static str> { Html("