use axum::http::StatusCode; use axum::response::IntoResponse; use axum::routing::get; use axum::Router; use maud::html; struct AppError(anyhow::Error); impl IntoResponse for AppError { fn into_response(self) -> axum::response::Response { ( StatusCode::INTERNAL_SERVER_ERROR, format!("Something went wrong: {}", self.0), ) .into_response() } } impl From for AppError where E: Into, { fn from(err: E) -> Self { Self(err.into()) } } #[tokio::main] async fn main() { let app = Router::new().route("/", get(home)); let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap(); axum::serve(listener, app.into_make_service()) .await .unwrap(); } async fn home() -> Result { Ok(html!({})) }