1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-31 17:07:01 +02:00

make Reply generic over error too

This commit is contained in:
Nikolay Kim
2018-05-02 16:33:29 -07:00
parent 32a2866449
commit 7036656ae4
6 changed files with 112 additions and 138 deletions

View File

@@ -5,7 +5,7 @@ use std::rc::Rc;
use futures::{Async, Future, Poll};
use error::Error;
use handler::{FromRequest, Reply, ReplyItem, Responder, RouteHandler};
use handler::{FromRequest, Reply, ReplyResult, Responder, RouteHandler};
use http::Method;
use httprequest::HttpRequest;
use httpresponse::HttpResponse;
@@ -523,13 +523,12 @@ impl<S: 'static> WaitingResponse<S> {
#[inline]
fn init(info: &mut ComposeInfo<S>, reply: Reply<HttpResponse>) -> ComposeState<S> {
match reply.into() {
ReplyItem::Message(resp) => RunMiddlewares::init(info, resp),
ReplyItem::Error(err) => RunMiddlewares::init(info, err.into()),
ReplyItem::Future(fut) => ComposeState::Handler(WaitingResponse {
ReplyResult::Ok(resp) => RunMiddlewares::init(info, resp),
ReplyResult::Err(err) => RunMiddlewares::init(info, err.into()),
ReplyResult::Future(fut) => ComposeState::Handler(WaitingResponse {
fut,
_s: PhantomData,
}),
ReplyItem::None => panic!("use after resolve"),
}
}