mirror of
https://github.com/fafhrd91/actix-web
synced 2025-01-30 18:42:52 +01:00
make resource handler result more generic
This commit is contained in:
parent
ac3fe30d19
commit
0bd8725426
@ -6,7 +6,7 @@ use http::Method;
|
|||||||
use futures::Stream;
|
use futures::Stream;
|
||||||
|
|
||||||
use task::Task;
|
use task::Task;
|
||||||
use error::{Result, Error};
|
use error::Error;
|
||||||
use route::{Route, RouteHandler, RouteResult, Frame, FnHandler, StreamHandler};
|
use route::{Route, RouteHandler, RouteResult, Frame, FnHandler, StreamHandler};
|
||||||
use context::HttpContext;
|
use context::HttpContext;
|
||||||
use httprequest::HttpRequest;
|
use httprequest::HttpRequest;
|
||||||
@ -63,7 +63,7 @@ impl<S> Resource<S> where S: 'static {
|
|||||||
|
|
||||||
/// Register handler for specified method.
|
/// Register handler for specified method.
|
||||||
pub fn handler<F, R>(&mut self, method: Method, handler: F)
|
pub fn handler<F, R>(&mut self, method: Method, handler: F)
|
||||||
where F: Fn(HttpRequest<S>) -> Result<R> + 'static,
|
where F: Fn(HttpRequest<S>) -> R + 'static,
|
||||||
R: Into<HttpResponse> + 'static,
|
R: Into<HttpResponse> + 'static,
|
||||||
{
|
{
|
||||||
self.routes.insert(method, Box::new(FnHandler::new(handler)));
|
self.routes.insert(method, Box::new(FnHandler::new(handler)));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user