Skip to content

Commit 21552fe

Browse files
authored
Remove bound from into_make_service_with_connect_info (#892)
Fixes #859
1 parent 2e5d56a commit 21552fe

7 files changed

Lines changed: 16 additions & 23 deletions

File tree

axum/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8888
- **changed:** Update to tokio-tungstenite 0.17 ([#791])
8989
- **breaking:** `Redirect::{to, temporary, permanent}` now accept `&str` instead
9090
of `Uri` ([#889])
91+
- **breaking:** Remove second type parameter from `Router::into_make_service_with_connect_info`
92+
and `Handler::into_make_service_with_connect_info` to support `MakeService`s
93+
that accept multiple targets ([#892])
9194

9295
[#644]: https://github.com/tokio-rs/axum/pull/644
9396
[#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
111114
[#842]: https://github.com/tokio-rs/axum/pull/842
112115
[#879]: https://github.com/tokio-rs/axum/pull/879
113116
[#889]: https://github.com/tokio-rs/axum/pull/889
117+
[#892]: https://github.com/tokio-rs/axum/pull/892
114118

115119
# 0.4.4 (13. January, 2022)
116120

axum/src/docs/routing/into_make_service_with_connect_info.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async fn handler(ConnectInfo(addr): ConnectInfo<SocketAddr>) -> String {
2323
# async {
2424
axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())
2525
.serve(
26-
app.into_make_service_with_connect_info::<SocketAddr, _>()
26+
app.into_make_service_with_connect_info::<SocketAddr>()
2727
)
2828
.await
2929
.expect("server failed");
@@ -64,7 +64,7 @@ impl Connected<&AddrStream> for MyConnectInfo {
6464
# async {
6565
axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())
6666
.serve(
67-
app.into_make_service_with_connect_info::<MyConnectInfo, _>()
67+
app.into_make_service_with_connect_info::<MyConnectInfo>()
6868
)
6969
.await
7070
.expect("server failed");

axum/src/extract/connect_info.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ mod tests {
161161
let app = Router::new().route("/", get(handler));
162162
let server = Server::from_tcp(listener)
163163
.unwrap()
164-
.serve(app.into_make_service_with_connect_info::<SocketAddr, _>());
164+
.serve(app.into_make_service_with_connect_info::<SocketAddr>());
165165
tx.send(()).unwrap();
166166
server.await.expect("server error");
167167
});
@@ -201,7 +201,7 @@ mod tests {
201201
let app = Router::new().route("/", get(handler));
202202
let server = Server::from_tcp(listener)
203203
.unwrap()
204-
.serve(app.into_make_service_with_connect_info::<MyConnectInfo, _>());
204+
.serve(app.into_make_service_with_connect_info::<MyConnectInfo>());
205205
tx.send(()).unwrap();
206206
server.await.expect("server error");
207207
});

axum/src/handler/mod.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,7 @@
7272
7373
use crate::{
7474
body::{boxed, Body, Bytes, HttpBody},
75-
extract::{
76-
connect_info::{Connected, IntoMakeServiceWithConnectInfo},
77-
FromRequest, RequestParts,
78-
},
75+
extract::{connect_info::IntoMakeServiceWithConnectInfo, FromRequest, RequestParts},
7976
response::{IntoResponse, Response},
8077
routing::IntoMakeService,
8178
BoxError,
@@ -230,20 +227,17 @@ pub trait Handler<T, B = Body>: Clone + Send + Sized + 'static {
230227
///
231228
/// # async {
232229
/// Server::bind(&SocketAddr::from(([127, 0, 0, 1], 3000)))
233-
/// .serve(handler.into_make_service_with_connect_info::<SocketAddr, _>())
230+
/// .serve(handler.into_make_service_with_connect_info::<SocketAddr>())
234231
/// .await?;
235232
/// # Ok::<_, hyper::Error>(())
236233
/// # };
237234
/// ```
238235
///
239236
/// [`MakeService`]: tower::make::MakeService
240237
/// [`Router::into_make_service_with_connect_info`]: crate::routing::Router::into_make_service_with_connect_info
241-
fn into_make_service_with_connect_info<C, Target>(
238+
fn into_make_service_with_connect_info<C>(
242239
self,
243-
) -> IntoMakeServiceWithConnectInfo<IntoService<Self, T, B>, C>
244-
where
245-
C: Connected<Target>,
246-
{
240+
) -> IntoMakeServiceWithConnectInfo<IntoService<Self, T, B>, C> {
247241
IntoMakeServiceWithConnectInfo::new(self.into_service())
248242
}
249243
}

axum/src/routing/mod.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use self::{future::RouteFuture, not_found::NotFound};
44
use crate::{
55
body::{boxed, Body, Bytes, HttpBody},
6-
extract::connect_info::{Connected, IntoMakeServiceWithConnectInfo},
6+
extract::connect_info::IntoMakeServiceWithConnectInfo,
77
response::{IntoResponse, Redirect, Response},
88
routing::strip_prefix::StripPrefix,
99
util::try_downcast,
@@ -405,12 +405,7 @@ where
405405
}
406406

407407
#[doc = include_str!("../docs/routing/into_make_service_with_connect_info.md")]
408-
pub fn into_make_service_with_connect_info<C, Target>(
409-
self,
410-
) -> IntoMakeServiceWithConnectInfo<Self, C>
411-
where
412-
C: Connected<Target>,
413-
{
408+
pub fn into_make_service_with_connect_info<C>(self) -> IntoMakeServiceWithConnectInfo<Self, C> {
414409
IntoMakeServiceWithConnectInfo::new(self)
415410
}
416411

examples/low-level-rustls/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async fn main() {
4141

4242
let mut app = Router::new()
4343
.route("/", get(handler))
44-
.into_make_service_with_connect_info::<SocketAddr, _>();
44+
.into_make_service_with_connect_info::<SocketAddr>();
4545

4646
loop {
4747
let stream = poll_fn(|cx| Pin::new(&mut listener).poll_accept(cx))

examples/unix-domain-socket/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ async fn main() {
5757
let app = Router::new().route("/", get(handler));
5858

5959
axum::Server::builder(ServerAccept { uds })
60-
.serve(app.into_make_service_with_connect_info::<UdsConnectInfo, _>())
60+
.serve(app.into_make_service_with_connect_info::<UdsConnectInfo>())
6161
.await
6262
.unwrap();
6363
});

0 commit comments

Comments
 (0)