pub mod auth;
pub mod operational_state;
pub mod permission;
pub mod request_id;
use axum::http::StatusCode;
use axum::middleware;
use axum::Router;
use std::time::Duration;
use tower_http::cors::CorsLayer;
use tower_http::timeout::TimeoutLayer;
use tower_http::trace::TraceLayer;
use crate::web::state::AppState;
#[expect(
dead_code,
reason = "pub(crate) web infrastructure used by route configuration"
)]
pub fn apply_middleware_stack(router: Router<AppState>) -> Router<AppState> {
router
.layer(middleware::from_fn(request_id::add_request_id))
.layer(TimeoutLayer::with_status_code(
StatusCode::REQUEST_TIMEOUT,
Duration::from_secs(30),
))
.layer(create_cors_layer())
.layer(TraceLayer::new_for_http())
}
#[cfg(feature = "test-utils")]
#[expect(
dead_code,
reason = "pub(crate) web infrastructure used by route configuration"
)]
pub fn apply_test_middleware_stack(router: Router<AppState>) -> Router<AppState> {
router
.layer(middleware::from_fn(request_id::add_request_id))
.layer(TimeoutLayer::with_status_code(
StatusCode::REQUEST_TIMEOUT,
Duration::from_secs(120),
)) .layer(create_cors_layer())
.layer(TraceLayer::new_for_http())
}
fn create_cors_layer() -> CorsLayer {
CorsLayer::new()
.allow_origin(tower_http::cors::Any) .allow_methods(tower_http::cors::Any)
.allow_headers(tower_http::cors::Any)
}