mirror of
https://github.com/fafhrd91/actix-web
synced 2025-08-20 12:45:41 +02:00
pass request by ref; added middleware support
This commit is contained in:
@@ -58,7 +58,7 @@ impl<S> Resource<S> where S: 'static {
|
||||
|
||||
/// Register handler for specified method.
|
||||
pub fn handler<F, R>(&mut self, method: Method, handler: F)
|
||||
where F: Fn(HttpRequest, Payload, &S) -> R + 'static,
|
||||
where F: Fn(&mut HttpRequest, Payload, &S) -> R + 'static,
|
||||
R: Into<HttpResponse> + 'static,
|
||||
{
|
||||
self.routes.insert(method, Box::new(FnHandler::new(handler)));
|
||||
@@ -66,7 +66,7 @@ impl<S> Resource<S> where S: 'static {
|
||||
|
||||
/// Register async handler for specified method.
|
||||
pub fn async<F, R>(&mut self, method: Method, handler: F)
|
||||
where F: Fn(HttpRequest, Payload, &S) -> R + 'static,
|
||||
where F: Fn(&mut HttpRequest, Payload, &S) -> R + 'static,
|
||||
R: Stream<Item=Frame, Error=()> + 'static,
|
||||
{
|
||||
self.routes.insert(method, Box::new(StreamHandler::new(handler)));
|
||||
@@ -119,7 +119,7 @@ impl<S> Resource<S> where S: 'static {
|
||||
|
||||
impl<S: 'static> RouteHandler<S> for Resource<S> {
|
||||
|
||||
fn handle(&self, req: HttpRequest, payload: Payload, state: Rc<S>) -> Task {
|
||||
fn handle(&self, req: &mut HttpRequest, payload: Payload, state: Rc<S>) -> Task {
|
||||
if let Some(handler) = self.routes.get(req.method()) {
|
||||
handler.handle(req, payload, state)
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user