diff --git a/examples/hello_world.rs b/examples/hello_world.rs
index 4b169700..b6b57b19 100644
--- a/examples/hello_world.rs
+++ b/examples/hello_world.rs
@@ -3,7 +3,7 @@ use hyper::Server;
use std::net::SocketAddr;
use tower::{make::Shared, ServiceBuilder};
use tower_http::trace::TraceLayer;
-use tower_web::{body::Body, response::Html, Error};
+use tower_web::{body::Body, response::Html};
#[tokio::main]
async fn main() {
@@ -28,6 +28,6 @@ async fn main() {
server.await.unwrap();
}
-async fn handler(_req: Request
) -> Result, Error> {
- Ok(Html("Hello, World!
"))
+async fn handler(_req: Request) -> Html<&'static str> {
+ Html("Hello, World!
")
}
diff --git a/examples/key_value_store.rs b/examples/key_value_store.rs
index 3bcfc3e3..02b5658c 100644
--- a/examples/key_value_store.rs
+++ b/examples/key_value_store.rs
@@ -72,7 +72,7 @@ async fn set(
params: extract::UrlParams<(String,)>,
value: extract::BytesMaxLength<{ 1024 * 5_000 }>, // ~5mb
state: extract::Extension,
-) -> Result {
+) -> response::Empty {
let state = state.into_inner();
let db = &mut state.lock().unwrap().db;
@@ -81,5 +81,5 @@ async fn set(
db.insert(key.to_string(), value);
- Ok(response::Empty)
+ response::Empty
}
diff --git a/examples/lots_of_routes.rs b/examples/lots_of_routes.rs
index 96b8ad71..dac28f85 100644
--- a/examples/lots_of_routes.rs
+++ b/examples/lots_of_routes.rs
@@ -2,7 +2,7 @@ use http::Request;
use hyper::Server;
use std::net::SocketAddr;
use tower::make::Shared;
-use tower_web::{body::Body, Error};
+use tower_web::body::Body;
#[tokio::main]
async fn main() {
@@ -227,6 +227,6 @@ async fn main() {
server.await.unwrap();
}
-async fn handler(_req: Request) -> Result<&'static str, Error> {
- Ok("Hello, World!")
+async fn handler(_req: Request) -> &'static str {
+ "Hello, World!"
}
diff --git a/src/handler.rs b/src/handler.rs
index 7c1787e7..24b24405 100644
--- a/src/handler.rs
+++ b/src/handler.rs
@@ -24,7 +24,7 @@ pub trait Handler: Sized {
#[doc(hidden)]
type Sealed: sealed::HiddentTrait;
- async fn call(self, req: Request) -> Result;
+ async fn call(self, req: Request) -> Result, Error>;
fn layer(self, layer: L) -> Layered
where
@@ -38,15 +38,15 @@ pub trait Handler: Sized {
impl Handler for F
where
F: Fn(Request) -> Fut + Send + Sync,
- Fut: Future