Skip to content

Commit 6e2c484

Browse files
committed
tower-http: Fix deprecation warning
1 parent 2570e01 commit 6e2c484

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/middleware.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use axum::Router;
1616
use axum::middleware::{ResponseAxumBodyLayer, from_fn, from_fn_with_state};
1717
use axum_extra::either::Either;
1818
use axum_extra::middleware::option_layer;
19+
use http::StatusCode;
1920
use std::time::Duration;
2021
use tower::layer::util::Identity;
2122
use tower_http::add_extension::AddExtensionLayer;
@@ -85,7 +86,10 @@ pub fn apply_axum_middleware(state: AppState, router: Router<()>) -> Router {
8586
router
8687
.layer(middlewares_2)
8788
.layer(middlewares_1)
88-
.layer(TimeoutLayer::new(Duration::from_secs(30)))
89+
.layer(TimeoutLayer::with_status_code(
90+
StatusCode::REQUEST_TIMEOUT,
91+
Duration::from_secs(30),
92+
))
8993
.layer(RequestBodyTimeoutLayer::new(Duration::from_secs(30)))
9094
.layer(CompressionLayer::new().quality(CompressionLevel::Fastest))
9195
}

0 commit comments

Comments
 (0)