Add unique future types for all services (#157)

So we can more easily change them in the future.
This commit is contained in:
David Pedersen
2021-08-07 22:27:27 +02:00
committed by GitHub
parent 2389761ce7
commit 6ce355cca3
7 changed files with 106 additions and 14 deletions
+6 -4
View File
@@ -1,6 +1,6 @@
//! Routing between [`Service`]s.
use self::future::{BoxRouteFuture, EmptyRouterFuture, RouteFuture};
use self::future::{BoxRouteFuture, EmptyRouterFuture, NestedFuture, RouteFuture};
use crate::{
body::{box_body, BoxBody},
buffer::MpscBuffer,
@@ -898,7 +898,7 @@ where
{
type Response = Response<BoxBody>;
type Error = S::Error;
type Future = RouteFuture<S, F, B>;
type Future = NestedFuture<S, F, B>;
fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
@@ -910,7 +910,7 @@ where
req.extensions_mut().insert(original_uri);
}
if let Some((prefix, captures)) = self.pattern.prefix_match(req.uri().path()) {
let f = if let Some((prefix, captures)) = self.pattern.prefix_match(req.uri().path()) {
let without_prefix = strip_prefix(req.uri(), prefix);
*req.uri_mut() = without_prefix;
@@ -920,7 +920,9 @@ where
} else {
let fut = self.fallback.clone().oneshot(req);
RouteFuture::b(fut)
}
};
NestedFuture { inner: f }
}
}