mirror of
https://github.com/tokio-rs/axum.git
synced 2025-09-27 13:00:39 +00:00
Remove bound from into_make_service_with_connect_info
(#892)
Fixes #859
This commit is contained in:
parent
2e5d56a9b1
commit
21552fe434
@ -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])
|
- **changed:** Update to tokio-tungstenite 0.17 ([#791])
|
||||||
- **breaking:** `Redirect::{to, temporary, permanent}` now accept `&str` instead
|
- **breaking:** `Redirect::{to, temporary, permanent}` now accept `&str` instead
|
||||||
of `Uri` ([#889])
|
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
|
[#644]: https://github.com/tokio-rs/axum/pull/644
|
||||||
[#665]: https://github.com/tokio-rs/axum/pull/665
|
[#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
|
[#842]: https://github.com/tokio-rs/axum/pull/842
|
||||||
[#879]: https://github.com/tokio-rs/axum/pull/879
|
[#879]: https://github.com/tokio-rs/axum/pull/879
|
||||||
[#889]: https://github.com/tokio-rs/axum/pull/889
|
[#889]: https://github.com/tokio-rs/axum/pull/889
|
||||||
|
[#892]: https://github.com/tokio-rs/axum/pull/892
|
||||||
|
|
||||||
# 0.4.4 (13. January, 2022)
|
# 0.4.4 (13. January, 2022)
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ async fn handler(ConnectInfo(addr): ConnectInfo<SocketAddr>) -> String {
|
|||||||
# async {
|
# async {
|
||||||
axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())
|
axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())
|
||||||
.serve(
|
.serve(
|
||||||
app.into_make_service_with_connect_info::<SocketAddr, _>()
|
app.into_make_service_with_connect_info::<SocketAddr>()
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.expect("server failed");
|
.expect("server failed");
|
||||||
@ -64,7 +64,7 @@ impl Connected<&AddrStream> for MyConnectInfo {
|
|||||||
# async {
|
# async {
|
||||||
axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())
|
axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())
|
||||||
.serve(
|
.serve(
|
||||||
app.into_make_service_with_connect_info::<MyConnectInfo, _>()
|
app.into_make_service_with_connect_info::<MyConnectInfo>()
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.expect("server failed");
|
.expect("server failed");
|
||||||
|
@ -161,7 +161,7 @@ mod tests {
|
|||||||
let app = Router::new().route("/", get(handler));
|
let app = Router::new().route("/", get(handler));
|
||||||
let server = Server::from_tcp(listener)
|
let server = Server::from_tcp(listener)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.serve(app.into_make_service_with_connect_info::<SocketAddr, _>());
|
.serve(app.into_make_service_with_connect_info::<SocketAddr>());
|
||||||
tx.send(()).unwrap();
|
tx.send(()).unwrap();
|
||||||
server.await.expect("server error");
|
server.await.expect("server error");
|
||||||
});
|
});
|
||||||
@ -201,7 +201,7 @@ mod tests {
|
|||||||
let app = Router::new().route("/", get(handler));
|
let app = Router::new().route("/", get(handler));
|
||||||
let server = Server::from_tcp(listener)
|
let server = Server::from_tcp(listener)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.serve(app.into_make_service_with_connect_info::<MyConnectInfo, _>());
|
.serve(app.into_make_service_with_connect_info::<MyConnectInfo>());
|
||||||
tx.send(()).unwrap();
|
tx.send(()).unwrap();
|
||||||
server.await.expect("server error");
|
server.await.expect("server error");
|
||||||
});
|
});
|
||||||
|
@ -72,10 +72,7 @@
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
body::{boxed, Body, Bytes, HttpBody},
|
body::{boxed, Body, Bytes, HttpBody},
|
||||||
extract::{
|
extract::{connect_info::IntoMakeServiceWithConnectInfo, FromRequest, RequestParts},
|
||||||
connect_info::{Connected, IntoMakeServiceWithConnectInfo},
|
|
||||||
FromRequest, RequestParts,
|
|
||||||
},
|
|
||||||
response::{IntoResponse, Response},
|
response::{IntoResponse, Response},
|
||||||
routing::IntoMakeService,
|
routing::IntoMakeService,
|
||||||
BoxError,
|
BoxError,
|
||||||
@ -230,7 +227,7 @@ pub trait Handler<T, B = Body>: Clone + Send + Sized + 'static {
|
|||||||
///
|
///
|
||||||
/// # async {
|
/// # async {
|
||||||
/// Server::bind(&SocketAddr::from(([127, 0, 0, 1], 3000)))
|
/// Server::bind(&SocketAddr::from(([127, 0, 0, 1], 3000)))
|
||||||
/// .serve(handler.into_make_service_with_connect_info::<SocketAddr, _>())
|
/// .serve(handler.into_make_service_with_connect_info::<SocketAddr>())
|
||||||
/// .await?;
|
/// .await?;
|
||||||
/// # Ok::<_, hyper::Error>(())
|
/// # Ok::<_, hyper::Error>(())
|
||||||
/// # };
|
/// # };
|
||||||
@ -238,12 +235,9 @@ pub trait Handler<T, B = Body>: Clone + Send + Sized + 'static {
|
|||||||
///
|
///
|
||||||
/// [`MakeService`]: tower::make::MakeService
|
/// [`MakeService`]: tower::make::MakeService
|
||||||
/// [`Router::into_make_service_with_connect_info`]: crate::routing::Router::into_make_service_with_connect_info
|
/// [`Router::into_make_service_with_connect_info`]: crate::routing::Router::into_make_service_with_connect_info
|
||||||
fn into_make_service_with_connect_info<C, Target>(
|
fn into_make_service_with_connect_info<C>(
|
||||||
self,
|
self,
|
||||||
) -> IntoMakeServiceWithConnectInfo<IntoService<Self, T, B>, C>
|
) -> IntoMakeServiceWithConnectInfo<IntoService<Self, T, B>, C> {
|
||||||
where
|
|
||||||
C: Connected<Target>,
|
|
||||||
{
|
|
||||||
IntoMakeServiceWithConnectInfo::new(self.into_service())
|
IntoMakeServiceWithConnectInfo::new(self.into_service())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
use self::{future::RouteFuture, not_found::NotFound};
|
use self::{future::RouteFuture, not_found::NotFound};
|
||||||
use crate::{
|
use crate::{
|
||||||
body::{boxed, Body, Bytes, HttpBody},
|
body::{boxed, Body, Bytes, HttpBody},
|
||||||
extract::connect_info::{Connected, IntoMakeServiceWithConnectInfo},
|
extract::connect_info::IntoMakeServiceWithConnectInfo,
|
||||||
response::{IntoResponse, Redirect, Response},
|
response::{IntoResponse, Redirect, Response},
|
||||||
routing::strip_prefix::StripPrefix,
|
routing::strip_prefix::StripPrefix,
|
||||||
util::try_downcast,
|
util::try_downcast,
|
||||||
@ -405,12 +405,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[doc = include_str!("../docs/routing/into_make_service_with_connect_info.md")]
|
#[doc = include_str!("../docs/routing/into_make_service_with_connect_info.md")]
|
||||||
pub fn into_make_service_with_connect_info<C, Target>(
|
pub fn into_make_service_with_connect_info<C>(self) -> IntoMakeServiceWithConnectInfo<Self, C> {
|
||||||
self,
|
|
||||||
) -> IntoMakeServiceWithConnectInfo<Self, C>
|
|
||||||
where
|
|
||||||
C: Connected<Target>,
|
|
||||||
{
|
|
||||||
IntoMakeServiceWithConnectInfo::new(self)
|
IntoMakeServiceWithConnectInfo::new(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ async fn main() {
|
|||||||
|
|
||||||
let mut app = Router::new()
|
let mut app = Router::new()
|
||||||
.route("/", get(handler))
|
.route("/", get(handler))
|
||||||
.into_make_service_with_connect_info::<SocketAddr, _>();
|
.into_make_service_with_connect_info::<SocketAddr>();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let stream = poll_fn(|cx| Pin::new(&mut listener).poll_accept(cx))
|
let stream = poll_fn(|cx| Pin::new(&mut listener).poll_accept(cx))
|
||||||
|
@ -57,7 +57,7 @@ async fn main() {
|
|||||||
let app = Router::new().route("/", get(handler));
|
let app = Router::new().route("/", get(handler));
|
||||||
|
|
||||||
axum::Server::builder(ServerAccept { uds })
|
axum::Server::builder(ServerAccept { uds })
|
||||||
.serve(app.into_make_service_with_connect_info::<UdsConnectInfo, _>())
|
.serve(app.into_make_service_with_connect_info::<UdsConnectInfo>())
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user