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:
10
src/route.rs
10
src/route.rs
@@ -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));
|
||||
}
|
||||
|
Reference in New Issue
Block a user