Skip to content

svelterust/axum-error

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

axum-error

cargo add axum-error

Provides an Error type which can be used in a eyre-like fashion for axum, as well as simple error handling with fehler.

use axum::{response::Html, routing::get, Router};
use std::{fs::read_to_string, net::SocketAddr};
use axum_error::*;
 
#[throws]
#[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?;
}
 
#[throws]
async fn index() -> Html<String> {
    Html(read_to_string("index.html")?)
}

About

Simple error handling for axum

Topics

Resources

Stars

Watchers

Forks

Languages