diff --git a/axum/CHANGELOG.md b/axum/CHANGELOG.md index 628b3ef8..acb31f5b 100644 --- a/axum/CHANGELOG.md +++ b/axum/CHANGELOG.md @@ -88,6 +88,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **changed:** Update to tokio-tungstenite 0.17 ([#791]) - **breaking:** `Redirect::{to, temporary, permanent}` now accept `&str` instead of `Uri` ([#889]) +- **breaking:** Remove second type parameter from `Router::into_make_service_with_connect_info` + and `Handler::into_make_service_with_connect_info` to support `MakeService`s + that accept multiple targets ([#892]) [#644]: https://github.com/tokio-rs/axum/pull/644 [#665]: https://github.com/tokio-rs/axum/pull/665 @@ -111,6 +114,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#842]: https://github.com/tokio-rs/axum/pull/842 [#879]: https://github.com/tokio-rs/axum/pull/879 [#889]: https://github.com/tokio-rs/axum/pull/889 +[#892]: https://github.com/tokio-rs/axum/pull/892 # 0.4.4 (13. January, 2022) diff --git a/axum/src/docs/routing/into_make_service_with_connect_info.md b/axum/src/docs/routing/into_make_service_with_connect_info.md index f2040c7f..05ee750c 100644 --- a/axum/src/docs/routing/into_make_service_with_connect_info.md +++ b/axum/src/docs/routing/into_make_service_with_connect_info.md @@ -23,7 +23,7 @@ async fn handler(ConnectInfo(addr): ConnectInfo) -> String { # async { axum::Server::bind(&"0.0.0.0:3000".parse().unwrap()) .serve( - app.into_make_service_with_connect_info::() + app.into_make_service_with_connect_info::() ) .await .expect("server failed"); @@ -64,7 +64,7 @@ impl Connected<&AddrStream> for MyConnectInfo { # async { axum::Server::bind(&"0.0.0.0:3000".parse().unwrap()) .serve( - app.into_make_service_with_connect_info::() + app.into_make_service_with_connect_info::() ) .await .expect("server failed"); diff --git a/axum/src/extract/connect_info.rs b/axum/src/extract/connect_info.rs index 004e1d83..8363a25e 100644 --- a/axum/src/extract/connect_info.rs +++ b/axum/src/extract/connect_info.rs @@ -161,7 +161,7 @@ mod tests { let app = Router::new().route("/", get(handler)); let server = Server::from_tcp(listener) .unwrap() - .serve(app.into_make_service_with_connect_info::()); + .serve(app.into_make_service_with_connect_info::()); tx.send(()).unwrap(); server.await.expect("server error"); }); @@ -201,7 +201,7 @@ mod tests { let app = Router::new().route("/", get(handler)); let server = Server::from_tcp(listener) .unwrap() - .serve(app.into_make_service_with_connect_info::()); + .serve(app.into_make_service_with_connect_info::()); tx.send(()).unwrap(); server.await.expect("server error"); }); diff --git a/axum/src/handler/mod.rs b/axum/src/handler/mod.rs index 5818a70a..d109a579 100644 --- a/axum/src/handler/mod.rs +++ b/axum/src/handler/mod.rs @@ -72,10 +72,7 @@ use crate::{ body::{boxed, Body, Bytes, HttpBody}, - extract::{ - connect_info::{Connected, IntoMakeServiceWithConnectInfo}, - FromRequest, RequestParts, - }, + extract::{connect_info::IntoMakeServiceWithConnectInfo, FromRequest, RequestParts}, response::{IntoResponse, Response}, routing::IntoMakeService, BoxError, @@ -230,7 +227,7 @@ pub trait Handler: Clone + Send + Sized + 'static { /// /// # async { /// Server::bind(&SocketAddr::from(([127, 0, 0, 1], 3000))) - /// .serve(handler.into_make_service_with_connect_info::()) + /// .serve(handler.into_make_service_with_connect_info::()) /// .await?; /// # Ok::<_, hyper::Error>(()) /// # }; @@ -238,12 +235,9 @@ pub trait Handler: Clone + Send + Sized + 'static { /// /// [`MakeService`]: tower::make::MakeService /// [`Router::into_make_service_with_connect_info`]: crate::routing::Router::into_make_service_with_connect_info - fn into_make_service_with_connect_info( + fn into_make_service_with_connect_info( self, - ) -> IntoMakeServiceWithConnectInfo, C> - where - C: Connected, - { + ) -> IntoMakeServiceWithConnectInfo, C> { IntoMakeServiceWithConnectInfo::new(self.into_service()) } } diff --git a/axum/src/routing/mod.rs b/axum/src/routing/mod.rs index 3165422b..0a00c22b 100644 --- a/axum/src/routing/mod.rs +++ b/axum/src/routing/mod.rs @@ -3,7 +3,7 @@ use self::{future::RouteFuture, not_found::NotFound}; use crate::{ body::{boxed, Body, Bytes, HttpBody}, - extract::connect_info::{Connected, IntoMakeServiceWithConnectInfo}, + extract::connect_info::IntoMakeServiceWithConnectInfo, response::{IntoResponse, Redirect, Response}, routing::strip_prefix::StripPrefix, util::try_downcast, @@ -405,12 +405,7 @@ where } #[doc = include_str!("../docs/routing/into_make_service_with_connect_info.md")] - pub fn into_make_service_with_connect_info( - self, - ) -> IntoMakeServiceWithConnectInfo - where - C: Connected, - { + pub fn into_make_service_with_connect_info(self) -> IntoMakeServiceWithConnectInfo { IntoMakeServiceWithConnectInfo::new(self) } diff --git a/examples/low-level-rustls/src/main.rs b/examples/low-level-rustls/src/main.rs index 31215899..103cbcfc 100644 --- a/examples/low-level-rustls/src/main.rs +++ b/examples/low-level-rustls/src/main.rs @@ -41,7 +41,7 @@ async fn main() { let mut app = Router::new() .route("/", get(handler)) - .into_make_service_with_connect_info::(); + .into_make_service_with_connect_info::(); loop { let stream = poll_fn(|cx| Pin::new(&mut listener).poll_accept(cx)) diff --git a/examples/unix-domain-socket/src/main.rs b/examples/unix-domain-socket/src/main.rs index 6dbcec33..46096603 100644 --- a/examples/unix-domain-socket/src/main.rs +++ b/examples/unix-domain-socket/src/main.rs @@ -57,7 +57,7 @@ async fn main() { let app = Router::new().route("/", get(handler)); axum::Server::builder(ServerAccept { uds }) - .serve(app.into_make_service_with_connect_info::()) + .serve(app.into_make_service_with_connect_info::()) .await .unwrap(); });