Expand description
Provides an Error
type which can be used in a eyre
-like fashion
for axum
use axum::{response::Html, routing::get, Router};
use std::{fs::read_to_string, net::SocketAddr};
use axum_error::Result;
#[tokio::main]
async fn main() {
let app = Router::new().route("/", get(index));
axum::Server::bind(&SocketAddr::from(([127, 0, 0, 1], 3000)))
.serve(app.into_make_service())
.await
.unwrap()
}
async fn index() -> Result<Html<String>> {
Ok(Html(read_to_string("index.html")?))
}
Structs§
- Error
- Error type which implements
IntoResponse