1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-20 12:45:41 +02:00

hide httpresponse box

This commit is contained in:
Nikolay Kim
2017-12-15 16:24:15 -08:00
parent c3d5e4301a
commit 1ddcce7b76
8 changed files with 172 additions and 82 deletions

View File

@@ -54,7 +54,7 @@ impl<F, R, S> Handler<S> for F
pub struct Reply(ReplyItem);
pub(crate) enum ReplyItem {
Message(Box<HttpResponse>),
Message(HttpResponse),
Actor(Box<IoContext>),
Future(Box<Future<Item=HttpResponse, Error=Error>>),
}
@@ -80,7 +80,7 @@ impl Reply {
/// Send response
#[inline]
pub fn response<R: Into<HttpResponse>>(response: R) -> Reply {
Reply(ReplyItem::Message(Box::new(response.into())))
Reply(ReplyItem::Message(response.into()))
}
#[inline]
@@ -111,14 +111,14 @@ impl Responder for HttpResponse {
type Error = Error;
fn respond_to(self, _: HttpRequest) -> Result<Reply, Error> {
Ok(Reply(ReplyItem::Message(Box::new(self))))
Ok(Reply(ReplyItem::Message(self)))
}
}
impl From<HttpResponse> for Reply {
fn from(resp: HttpResponse) -> Reply {
Reply(ReplyItem::Message(Box::new(resp)))
Reply(ReplyItem::Message(resp))
}
}
@@ -142,7 +142,7 @@ impl<E: Into<Error>> From<Result<Reply, E>> for Reply {
fn from(res: Result<Reply, E>) -> Self {
match res {
Ok(val) => val,
Err(err) => Reply(ReplyItem::Message(Box::new(err.into().into()))),
Err(err) => Reply(ReplyItem::Message(err.into().into())),
}
}
}