Skip to content

Commit 3fb52b0

Browse files
authored
Address tower-http deprecated warning (#3672)
1 parent 6a03c63 commit 3fb52b0

File tree

6 files changed

+25
-9
lines changed

6 files changed

+25
-9
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.

axum/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ tracing = { version = "0.1", default-features = false, optional = true }
143143
serde = { version = "1.0.211", optional = true }
144144

145145
[dependencies.tower-http]
146-
version = "0.6.0"
146+
version = "0.6.8"
147147
optional = true
148148
features = [
149149
# all tower-http features except (de)?compression-zstd which doesn't
@@ -208,7 +208,7 @@ features = [
208208
]
209209

210210
[dev-dependencies.tower-http]
211-
version = "0.6.0"
211+
version = "0.6.8"
212212
features = [
213213
# all tower-http features except (de)?compression-zstd which doesn't
214214
# build on `--target armv5te-unknown-linux-musleabi`

axum/src/handler/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,10 @@ mod tests {
431431
let svc = handle
432432
.layer((
433433
RequestBodyLimitLayer::new(1024),
434-
TimeoutLayer::new(Duration::from_secs(10)),
434+
TimeoutLayer::with_status_code(
435+
StatusCode::REQUEST_TIMEOUT,
436+
Duration::from_secs(10),
437+
),
435438
MapResponseBodyLayer::new(Body::new),
436439
))
437440
.layer(MapRequestBodyLayer::new(Body::new))

axum/src/routing/method_routing.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,6 +1457,7 @@ mod tests {
14571457
assert_eq!(status, StatusCode::OK);
14581458
}
14591459

1460+
#[allow(deprecated)]
14601461
#[crate::test]
14611462
async fn layer() {
14621463
let mut svc = MethodRouter::new()
@@ -1472,6 +1473,7 @@ mod tests {
14721473
assert_eq!(status, StatusCode::UNAUTHORIZED);
14731474
}
14741475

1476+
#[allow(deprecated)]
14751477
#[crate::test]
14761478
async fn route_layer() {
14771479
let mut svc = MethodRouter::new()
@@ -1487,7 +1489,7 @@ mod tests {
14871489
assert_eq!(status, StatusCode::METHOD_NOT_ALLOWED);
14881490
}
14891491

1490-
#[allow(dead_code)]
1492+
#[allow(dead_code, deprecated)]
14911493
async fn building_complex_router() {
14921494
let app = crate::Router::new().route(
14931495
"/",
@@ -1498,7 +1500,10 @@ mod tests {
14981500
.merge(delete_service(ServeDir::new(".")))
14991501
.fallback(|| async { StatusCode::NOT_FOUND })
15001502
.put(ok)
1501-
.layer(TimeoutLayer::new(Duration::from_secs(10))),
1503+
.layer(TimeoutLayer::with_status_code(
1504+
StatusCode::REQUEST_TIMEOUT,
1505+
Duration::from_secs(10),
1506+
)),
15021507
);
15031508

15041509
let listener = tokio::net::TcpListener::bind("0.0.0.0:0").await.unwrap();

axum/src/routing/tests/merge.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,10 @@ async fn layer_and_handle_error() {
127127
let one = Router::new().route("/foo", get(|| async {}));
128128
let two = Router::new()
129129
.route("/timeout", get(std::future::pending::<()>))
130-
.layer(TimeoutLayer::new(Duration::from_millis(10)));
130+
.layer(TimeoutLayer::with_status_code(
131+
StatusCode::REQUEST_TIMEOUT,
132+
Duration::from_millis(10),
133+
));
131134
let app = one.merge(two);
132135

133136
let client = TestClient::new(app);
@@ -364,6 +367,7 @@ async fn nesting_and_seeing_the_right_uri_ors_with_multi_segment_uris() {
364367
);
365368
}
366369

370+
#[allow(deprecated)]
367371
#[crate::test]
368372
async fn middleware_that_return_early() {
369373
let private = Router::new()

axum/src/routing/tests/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,10 @@ async fn wildcard_sees_whole_url() {
330330
async fn middleware_applies_to_routes_above() {
331331
let app = Router::new()
332332
.route("/one", get(std::future::pending::<()>))
333-
.layer(TimeoutLayer::new(Duration::ZERO))
333+
.layer(TimeoutLayer::with_status_code(
334+
StatusCode::REQUEST_TIMEOUT,
335+
Duration::ZERO,
336+
))
334337
.route("/two", get(|| async {}));
335338

336339
let client = TestClient::new(app);
@@ -586,6 +589,7 @@ async fn routing_to_router_panics() {
586589
TestClient::new(Router::new().route_service("/", Router::new()));
587590
}
588591

592+
#[allow(deprecated)]
589593
#[crate::test]
590594
async fn route_layer() {
591595
let app = Router::new()

0 commit comments

Comments
 (0)