diff --git a/src/route.rs b/src/route.rs index 8cc1edfc2..45efd9e3c 100644 --- a/src/route.rs +++ b/src/route.rs @@ -16,24 +16,24 @@ use crate::responder::Responder; use crate::service::{ServiceRequest, ServiceResponse}; use crate::HttpResponse; -type BoxedRouteService = Box< +type BoxedRouteService = Box< dyn Service< - Request = Req, - Response = Res, + Request = ServiceRequest, + Response = ServiceResponse, Error = Error, - Future = LocalBoxFuture<'static, Result>, + Future = LocalBoxFuture<'static, Result>, >, >; -type BoxedRouteNewService = Box< +type BoxedRouteNewService = Box< dyn ServiceFactory< Config = (), - Request = Req, - Response = Res, + Request = ServiceRequest, + Response = ServiceResponse, Error = Error, InitError = (), - Service = BoxedRouteService, - Future = LocalBoxFuture<'static, Result, ()>>, + Service = BoxedRouteService, + Future = LocalBoxFuture<'static, Result>, >, >; @@ -42,7 +42,7 @@ type BoxedRouteNewService = Box< /// Route uses builder-like pattern for configuration. /// If handler is not explicitly set, default *404 Not Found* handler is used. pub struct Route { - service: BoxedRouteNewService, + service: BoxedRouteNewService, guards: Rc>>, } @@ -80,15 +80,8 @@ impl ServiceFactory for Route { } } -type RouteFuture = LocalBoxFuture< - 'static, - Result, ()>, ->; - -#[pin_project::pin_project] pub struct CreateRouteService { - #[pin] - fut: RouteFuture, + fut: LocalBoxFuture<'static, Result>, guards: Rc>>, } @@ -96,9 +89,9 @@ impl Future for CreateRouteService { type Output = Result; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - let this = self.project(); + let this = self.get_mut(); - match this.fut.poll(cx)? { + match this.fut.as_mut().poll(cx)? { Poll::Ready(service) => Poll::Ready(Ok(RouteService { service, guards: this.guards.clone(), @@ -109,7 +102,7 @@ impl Future for CreateRouteService { } pub struct RouteService { - service: BoxedRouteService, + service: BoxedRouteService, guards: Rc>>, } @@ -275,12 +268,12 @@ where T::Service: 'static, ::Future: 'static, { - type Config = (); type Request = ServiceRequest; type Response = ServiceResponse; type Error = Error; + type Config = (); + type Service = BoxedRouteService; type InitError = (); - type Service = BoxedRouteService; type Future = LocalBoxFuture<'static, Result>; fn new_service(&self, _: ()) -> Self::Future { @@ -288,8 +281,7 @@ where .new_service(()) .map(|result| match result { Ok(service) => { - let service: BoxedRouteService<_, _> = - Box::new(RouteServiceWrapper { service }); + let service = Box::new(RouteServiceWrapper { service }) as _; Ok(service) } Err(_) => Err(()),