1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-25 22:56:02 +02:00

use sync method on Responder trait (#1891)

This commit is contained in:
fakeshadow
2021-01-09 06:17:19 +08:00
committed by GitHub
parent 2204614134
commit d40ae8c8ca
10 changed files with 221 additions and 300 deletions

View File

@@ -135,7 +135,6 @@ where
{
Extract(#[pin] T::Future, Option<HttpRequest>, F),
Handle(#[pin] R, Option<HttpRequest>),
Respond(#[pin] <R::Output as Responder>::Future, Option<HttpRequest>),
}
impl<F, T, R> Future for HandlerServiceFuture<F, T, R>
@@ -168,13 +167,8 @@ where
}
HandlerProj::Handle(fut, req) => {
let res = ready!(fut.poll(cx));
let fut = res.respond_to(req.as_ref().unwrap());
let state = HandlerServiceFuture::Respond(fut, req.take());
self.as_mut().set(state);
}
HandlerProj::Respond(fut, req) => {
let res = ready!(fut.poll(cx)).unwrap_or_else(|e| e.into().into());
let req = req.take().unwrap();
let res = res.respond_to(&req);
return Poll::Ready(Ok(ServiceResponse::new(req, res)));
}
}