diff --git a/src/dev.rs b/src/dev.rs index b342774..899bcb3 100644 --- a/src/dev.rs +++ b/src/dev.rs @@ -5,4 +5,3 @@ pub fn log(function: &F, message: &str) { std::any::type_name_of_val(function).replace("en::", ""), ); } - diff --git a/src/handlers/fixed.rs b/src/handlers/fixed.rs index f215c4f..c9b0fb0 100644 --- a/src/handlers/fixed.rs +++ b/src/handlers/fixed.rs @@ -6,7 +6,6 @@ use axum::{ use crate::formats::{Format, populate_graph, serialize_graph}; use crate::handlers; -#[expect(clippy::unused_async)] pub async fn file(file_path: &str, content_type: &str) -> Response { let content = match std::fs::read(file_path) { Ok(s) => s, @@ -23,15 +22,19 @@ pub async fn file(file_path: &str, content_type: &str) -> Response { if let Some(h) = response.headers_mut().insert(header, header_value) { crate::dev::log( &file, - &format!("Overwrote existing header {h:?} because a header for \ - the same key existed") + &format!( + "Overwrote existing header {h:?} because a header for \ + the same key existed" + ), ); } } else { crate::dev::log( &file, - &format!("[file_handler] Failed to create content type \ - header value from {content_type}") + &format!( + "Failed to create content type \ + header value from {content_type}" + ), ); } diff --git a/src/handlers/raw.rs b/src/handlers/raw.rs index bb9c6aa..13a8ccb 100644 --- a/src/handlers/raw.rs +++ b/src/handlers/raw.rs @@ -20,15 +20,17 @@ pub fn make_response( { crate::dev::log( &make_response, - &format!("Overwrote header {overwritten:?} \ + &format!( + "Overwrote header {overwritten:?} \ because another for key {} already existed", - header.0) + header.0 + ), ); } } else { crate::dev::log( &make_response, - &format!("Failed to wrap header value {}", header.1) + &format!("Failed to wrap header value {}", header.1), ); } } diff --git a/src/handlers/template.rs b/src/handlers/template.rs index 4ba081d..b511e27 100644 --- a/src/handlers/template.rs +++ b/src/handlers/template.rs @@ -19,6 +19,7 @@ pub(super) fn by_filename( make_response(&body, status_code, &[(header::CONTENT_TYPE, "text/html")]) } +#[expect(clippy::unused_async)] pub async fn fixed(name: &str) -> Response { by_filename(name, &tera::Context::new(), 500, None, false) } diff --git a/src/main.rs b/src/main.rs index eadd325..e47ffa1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,24 +28,36 @@ async fn main() { if trace.status() == std::backtrace::BacktraceStatus::Captured { eprintln!("\n Stack trace:\n{trace:#?}"); } - })); let app = Router::new() - .route("/", get(|| handlers::navigation::nexus("index.html")) - .post(handlers::navigation::search)) - .route("/graph/toml", get(|| handlers::fixed::serial(&Format::Toml))) - .route("/graph/json", get(|| handlers::fixed::serial(&Format::Json))) + .route( + "/", + get(|| handlers::navigation::nexus("index.html")) + .post(handlers::navigation::search), + ) + .route( + "/graph/toml", + get(|| handlers::fixed::serial(&Format::Toml)), + ) + .route( + "/graph/json", + get(|| handlers::fixed::serial(&Format::Json)), + ) .route( "/static/style.css", get(|| handlers::fixed::file("./static/style.css", "text/css")), ) .route( "/static/favicon.svg", - get(|| handlers::fixed::file("./static/favicon.svg", "image/svg+xml")), + get(|| { + handlers::fixed::file("./static/favicon.svg", "image/svg+xml") + }), + ) + .route( + "/node/{node_id}", + get(handlers::graph::node).post(handlers::graph::node), ) - .route("/node/{node_id}", get(handlers::graph::node) - .post(handlers::graph::node)) .route("/tree", get(|| handlers::navigation::nexus("tree.html"))) .route("/about", get(|| handlers::template::fixed("about.html"))) .route( @@ -65,7 +77,7 @@ async fn main() { &main, &format!( "Failed to serve application with axum::serve: {e:#?}" - ) + ), ); std::process::exit(1); },