docs: update deprecated TimeoutLayer::new in graceful-shutdown example (#3647)

This commit is contained in:
Haiqal
2026-02-09 13:05:57 +01:00
committed by GitHub
parent c972bcba96
commit 57e2455905
4 changed files with 10 additions and 9 deletions
+6 -6
View File
@@ -1141,7 +1141,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
"windows-sys 0.52.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -3461,7 +3461,7 @@ dependencies = [
"once_cell",
"socket2 0.5.10",
"tracing",
"windows-sys 0.52.0",
"windows-sys 0.60.2",
]
[[package]]
@@ -3770,7 +3770,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys",
"windows-sys 0.52.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -4450,7 +4450,7 @@ dependencies = [
"getrandom 0.3.4",
"once_cell",
"rustix",
"windows-sys 0.52.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -4739,9 +4739,9 @@ dependencies = [
[[package]]
name = "tower-http"
version = "0.6.6"
version = "0.6.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2"
checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8"
dependencies = [
"async-compression",
"base64 0.22.1",
+1 -1
View File
@@ -7,5 +7,5 @@ publish = false
[dependencies]
axum = { path = "../../axum", features = ["tracing"] }
tokio = { version = "1.0", features = ["full"] }
tower-http = { version = "0.6.1", features = ["timeout", "trace"] }
tower-http = { version = "0.6", features = ["timeout", "trace"] }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
+2 -2
View File
@@ -7,7 +7,7 @@
use std::time::Duration;
use axum::{routing::get, Router};
use axum::{http::StatusCode, routing::get, Router};
use tokio::net::TcpListener;
use tokio::signal;
use tokio::time::sleep;
@@ -39,7 +39,7 @@ async fn main() {
TraceLayer::new_for_http(),
// Graceful shutdown will wait for outstanding requests to complete. Add a timeout so
// requests don't hang forever.
TimeoutLayer::new(Duration::from_secs(10)),
TimeoutLayer::with_status_code(StatusCode::REQUEST_TIMEOUT, Duration::from_secs(10)),
));
// Create a `TcpListener` using tokio.
+1
View File
@@ -123,6 +123,7 @@ fn admin_routes() -> Router<SharedState> {
state.write().unwrap().db.remove(&key);
}
#[allow(deprecated)] // FIXME
Router::new()
.route("/keys", delete(delete_all_keys))
.route("/key/{key}", delete(remove_key))