mirror of
https://github.com/fafhrd91/actix-web
synced 2025-08-22 05:35:08 +02:00
include payload into request
This commit is contained in:
@@ -9,7 +9,6 @@ use futures::Stream;
|
||||
use task::Task;
|
||||
use error::{Result, Error};
|
||||
use route::{Route, RouteHandler, RouteResult, Frame, FnHandler, StreamHandler};
|
||||
use payload::Payload;
|
||||
use context::HttpContext;
|
||||
use httprequest::HttpRequest;
|
||||
use httpresponse::HttpResponse;
|
||||
@@ -65,7 +64,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(&mut HttpRequest, Payload, &S) -> Result<R> + 'static,
|
||||
where F: Fn(&mut HttpRequest, &S) -> Result<R> + 'static,
|
||||
R: Into<HttpResponse> + 'static,
|
||||
{
|
||||
self.routes.insert(method, Box::new(FnHandler::new(handler)));
|
||||
@@ -73,7 +72,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(&mut HttpRequest, Payload, &S) -> R + 'static,
|
||||
where F: Fn(&mut HttpRequest, &S) -> R + 'static,
|
||||
R: Stream<Item=Frame, Error=Error> + 'static,
|
||||
{
|
||||
self.routes.insert(method, Box::new(StreamHandler::new(handler)));
|
||||
@@ -126,11 +125,11 @@ impl<S> Resource<S> where S: 'static {
|
||||
|
||||
impl<S: 'static> RouteHandler<S> for Resource<S> {
|
||||
|
||||
fn handle(&self, req: &mut HttpRequest, payload: Payload, state: Rc<S>) -> Task {
|
||||
fn handle(&self, req: &mut HttpRequest, state: Rc<S>) -> Task {
|
||||
if let Some(handler) = self.routes.get(req.method()) {
|
||||
handler.handle(req, payload, state)
|
||||
handler.handle(req, state)
|
||||
} else {
|
||||
self.default.handle(req, payload, state)
|
||||
self.default.handle(req, state)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user