diff --git a/src/handler.rs b/src/handler.rs index cbca0aed6..186237b47 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -168,14 +168,26 @@ impl>, S: 'static> From> fo } } -impl Responder for Box> +impl Responder for Box> + where I: Responder + 'static, + E: Into + 'static { type Item = Reply; type Error = Error; #[inline] - fn respond_to(self, _: HttpRequest) -> Result { - Ok(Reply(ReplyItem::Future(self))) + fn respond_to(self, req: HttpRequest) -> Result { + let fut = self.map_err(|e| e.into()) + .then(move |r| { + match r.respond_to(req) { + Ok(reply) => match reply.into().0 { + ReplyItem::Message(resp) => ok(resp), + _ => panic!("Nested async replies are not supported"), + }, + Err(e) => err(e), + } + }); + Ok(Reply::async(fut)) } }