diff --git a/examples/axum-key-value-store/Cargo.toml b/examples/axum-key-value-store/Cargo.toml index 2ac9475e..c8775c9b 100644 --- a/examples/axum-key-value-store/Cargo.toml +++ b/examples/axum-key-value-store/Cargo.toml @@ -7,11 +7,10 @@ publish = false license = "MIT" [dependencies] -hyper = { version = "0.14.15", features = ["full"] } -tokio = { version = "1.2.0", features = ["full"] } +tokio = { version = "1.32.0", features = ["full"] } tower = { version = "0.4.13", features = ["full"] } tower-http = { path = "../../tower-http", features = ["full"] } tracing = "0.1" -tracing-subscriber = { version = "0.3.11", features = ["env-filter"] } -axum = "0.6" -clap = { version = "4.3.16", features = ["derive"] } +tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } +axum = "0.7" +clap = { version = "4.4.4", features = ["derive"] } diff --git a/examples/axum-key-value-store/src/main.rs b/examples/axum-key-value-store/src/main.rs index a5e5a327..2f1b42de 100644 --- a/examples/axum-key-value-store/src/main.rs +++ b/examples/axum-key-value-store/src/main.rs @@ -1,8 +1,3 @@ -fn main() { - eprintln!("this example has not yet been updated to hyper 1.0"); -} - -/* use axum::{ body::Bytes, extract::{Path, State}, @@ -18,6 +13,7 @@ use std::{ sync::{Arc, RwLock}, time::Duration, }; +use tokio::net::TcpListener; use tower::ServiceBuilder; use tower_http::{ timeout::TimeoutLayer, @@ -49,10 +45,12 @@ async fn main() { // Run our service let addr = SocketAddr::from((Ipv4Addr::UNSPECIFIED, config.port)); tracing::info!("Listening on {}", addr); - axum::Server::bind(&addr) - .serve(app().into_make_service()) - .await - .expect("server error"); + axum::serve( + TcpListener::bind(addr).await.expect("bind error"), + app().into_make_service(), + ) + .await + .expect("server error"); } fn app() -> Router { @@ -79,8 +77,6 @@ fn app() -> Router { .sensitive_response_headers(sensitive_headers) // Set a timeout .layer(TimeoutLayer::new(Duration::from_secs(10))) - // Box the response body so it implements `Default` which is required by axum - .map_response_body(axum::body::boxed) // Compress responses .compression() // Set a `Content-Type` if there isn't one already. @@ -113,4 +109,3 @@ async fn set_key(Path(path): Path, state: State, value: Bytes) // See https://github.com/tokio-rs/axum/blob/main/examples/testing/src/main.rs for an example of // how to test axum apps -*/