feat(web): add 10 second timeout layer

This commit is contained in:
2025-09-14 01:47:04 -05:00
parent 1b7d2d2824
commit 3dca896a35
3 changed files with 7 additions and 5 deletions

View File

@@ -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<Body>| {
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