diff --git a/examples/basic.rs b/examples/basic.rs index 8ae36d9c6..8ffedec16 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -5,6 +5,7 @@ extern crate env_logger; extern crate futures; use actix_web::*; +use actix_web::error::Result; use futures::stream::{once, Once}; /// somple handle @@ -32,8 +33,7 @@ fn index_async(req: &mut HttpRequest, _payload: Payload, state: &()) } /// handle with path parameters like `/user/{name}/` -fn with_param(req: &mut HttpRequest, _payload: Payload, state: &()) - -> HandlerResult +fn with_param(req: &mut HttpRequest, _payload: Payload, state: &()) -> Result { println!("{:?}", req); diff --git a/src/h2.rs b/src/h2.rs index 99e153420..baa3f452e 100644 --- a/src/h2.rs +++ b/src/h2.rs @@ -133,7 +133,7 @@ impl Http2 entry.task.disconnected() } }, - Ok(Async::Ready(Some((mut req, resp)))) => { + Ok(Async::Ready(Some((req, resp)))) => { not_ready = false; let (parts, body) = req.into_parts(); diff --git a/src/lib.rs b/src/lib.rs index 403a078e0..c0463aee4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -77,7 +77,7 @@ pub use httprequest::{HttpRequest, UrlEncoded}; pub use httpresponse::{HttpResponse, HttpResponseBuilder}; pub use payload::{Payload, PayloadItem}; pub use route::{Frame, Route, RouteFactory, RouteHandler, RouteResult}; -pub use resource::{Reply, Resource, HandlerResult}; +pub use resource::{Reply, Resource}; pub use recognizer::{Params, RouteRecognizer}; pub use server::HttpServer; pub use context::HttpContext; diff --git a/src/resource.rs b/src/resource.rs index b8ddcc2e1..3e1341501 100644 --- a/src/resource.rs +++ b/src/resource.rs @@ -8,7 +8,7 @@ use http::Method; use futures::Stream; use task::Task; -use error::Error; +use error::{Result, Error}; use route::{Route, RouteHandler, RouteResult, Frame, FnHandler, StreamHandler}; use payload::Payload; use context::HttpContext; @@ -16,9 +16,6 @@ use httprequest::HttpRequest; use httpresponse::HttpResponse; use httpcodes::{HTTPNotFound, HTTPMethodNotAllowed}; -/// Result of a resource handler function -pub type HandlerResult = Result; - /// Http resource /// /// `Resource` is an entry in route table which corresponds to requested URL. @@ -69,7 +66,7 @@ impl Resource where S: 'static { /// Register handler for specified method. pub fn handler(&mut self, method: Method, handler: F) - where F: Fn(&mut HttpRequest, Payload, &S) -> HandlerResult + 'static, + where F: Fn(&mut HttpRequest, Payload, &S) -> Result + 'static, R: Into + 'static, { self.routes.insert(method, Box::new(FnHandler::new(handler)));