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

make async handler future more generic

This commit is contained in:
Nikolay Kim
2017-12-20 12:51:39 -08:00
parent c3a39e026d
commit 813b56ebe5
3 changed files with 45 additions and 22 deletions

View File

@@ -5,8 +5,6 @@ use pred::Predicate;
use handler::{Reply, Handler, Responder, RouteHandler, AsyncHandler, WrapHandler};
use httpcodes::HTTPNotFound;
use httprequest::HttpRequest;
use httpresponse::HttpResponse;
/// Resource route definition
///
@@ -80,9 +78,11 @@ impl<S: 'static> Route<S> {
}
/// Set async handler function.
pub fn a<F, R>(&mut self, handler: F)
where F: Fn(HttpRequest<S>) -> R + 'static,
R: Future<Item=HttpResponse, Error=Error> + 'static,
pub fn a<H, R, F, E>(&mut self, handler: H)
where H: Fn(HttpRequest<S>) -> F + 'static,
F: Future<Item=R, Error=E> + 'static,
R: Responder + 'static,
E: Into<Error> + 'static
{
self.handler = Box::new(AsyncHandler::new(handler));
}