Skip to content

Commit 6b812bc

Browse files
authored
Merge pull request #12385 from rust-lang/renovate/tower-http-0.x
Update Rust crate tower-http to v0.6.7
2 parents 8ef9d54 + 6e2c484 commit 6b812bc

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ tokio-postgres = "=0.7.15"
139139
tokio-util = "=0.7.17"
140140
toml = "=0.9.8"
141141
tower = "=0.5.2"
142-
tower-http = { version = "=0.6.6", features = ["add-extension", "fs", "catch-panic", "timeout", "compression-full"] }
142+
tower-http = { version = "=0.6.7", features = ["add-extension", "fs", "catch-panic", "timeout", "compression-full"] }
143143
tracing = "=0.1.41"
144144
tracing-subscriber = { version = "=0.3.20", features = ["env-filter", "json"] }
145145
typomania = { version = "=0.1.2", default-features = false }

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)