Bring back Handler::into_service (#212)

It was removed as part of https://github.com/tokio-rs/axum/pull/184 but
I do actually think it has some utility. So makes sense to keep even if
axum doesn't use it directly for routing.
This commit is contained in:
David Pedersen
2021-08-19 21:16:44 +02:00
committed by GitHub
parent 421faceae3
commit 0fd17d4181
4 changed files with 139 additions and 1 deletions
+14 -1
View File
@@ -2,11 +2,15 @@
use crate::body::{box_body, BoxBody};
use crate::util::{Either, EitherProj};
use futures_util::{future::BoxFuture, ready};
use futures_util::{
future::{BoxFuture, Map},
ready,
};
use http::{Method, Request, Response};
use http_body::Empty;
use pin_project_lite::pin_project;
use std::{
convert::Infallible,
fmt,
future::Future,
pin::Pin,
@@ -59,3 +63,12 @@ where
f.debug_struct("OnMethodFuture").finish()
}
}
opaque_future! {
/// The response future for [`IntoService`](super::IntoService).
pub type IntoServiceFuture =
Map<
BoxFuture<'static, Response<BoxBody>>,
fn(Response<BoxBody>) -> Result<Response<BoxBody>, Infallible>,
>;
}