diff --git a/Cargo.lock b/Cargo.lock index 04b3ddc..e2e7948 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -218,7 +218,7 @@ dependencies = [ [[package]] name = "banner" -version = "0.3.3" +version = "0.3.4" dependencies = [ "anyhow", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 4cb19fc..cb3b349 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "banner" -version = "0.3.3" +version = "0.3.4" edition = "2024" default-run = "banner" @@ -44,7 +44,7 @@ governor = "0.10.1" once_cell = "1.21.3" serde_path_to_error = "0.1.17" num-format = "0.4.4" -tower-http = { version = "0.6.0", features = ["fs", "cors", "trace"] } +tower-http = { version = "0.6.0", features = ["fs", "cors", "trace", "timeout"] } rust-embed = { version = "8.0", features = ["debug-embed", "include-exclude"] } mime_guess = "2.0" clap = { version = "4.5", features = ["derive"] } diff --git a/src/web/routes.rs b/src/web/routes.rs index b5da3f4..b41ffc1 100644 --- a/src/web/routes.rs +++ b/src/web/routes.rs @@ -12,6 +12,7 @@ use http::header; use serde::Serialize; use serde_json::{Value, json}; use std::{collections::BTreeMap, sync::Arc, time::Duration}; +use tower_http::timeout::TimeoutLayer; use tower_http::{ classify::ServerErrorsFailureClass, cors::{Any, CorsLayer}, @@ -86,7 +87,7 @@ pub fn create_router(state: BannerState) -> Router { router = router.fallback(fallback); } - router.layer( + router.layer(( TraceLayer::new_for_http() .make_span_with(|request: &Request| { tracing::debug_span!("request", path = request.uri().path()) @@ -129,7 +130,8 @@ pub fn create_router(state: BannerState) -> Router { ); }, ), - ) + TimeoutLayer::new(Duration::from_secs(10)), + )) } /// Handler that extracts request information for caching