mirror of
https://github.com/tokio-rs/axum.git
synced 2026-09-07 00:00:12 +02:00
Address tower-http deprecated warning
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use axum::{routing::get, Router};
|
use axum::{http::StatusCode, routing::get, Router};
|
||||||
use tokio::net::TcpListener;
|
use tokio::net::TcpListener;
|
||||||
use tokio::signal;
|
use tokio::signal;
|
||||||
use tokio::time::sleep;
|
use tokio::time::sleep;
|
||||||
@@ -39,7 +39,7 @@ async fn main() {
|
|||||||
TraceLayer::new_for_http(),
|
TraceLayer::new_for_http(),
|
||||||
// Graceful shutdown will wait for outstanding requests to complete. Add a timeout so
|
// Graceful shutdown will wait for outstanding requests to complete. Add a timeout so
|
||||||
// requests don't hang forever.
|
// 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.
|
// Create a `TcpListener` using tokio.
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ async fn list_keys(State(state): State<SharedState>) -> String {
|
|||||||
.join("\n")
|
.join("\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
fn admin_routes() -> Router<SharedState> {
|
fn admin_routes() -> Router<SharedState> {
|
||||||
async fn delete_all_keys(State(state): State<SharedState>) {
|
async fn delete_all_keys(State(state): State<SharedState>) {
|
||||||
state.write().unwrap().db.clear();
|
state.write().unwrap().db.clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user