Allow errors (#26)

This changes error model to actually allow errors. I think if we're going to use this for things like tonic's route we need a more flexible error handling model. The same `handle_error` adaptors are still there but services aren't required to have `Infallible` as their error type. The error type is simply propagated all the way through.
This commit is contained in:
David Pedersen
2021-07-05 16:18:39 +02:00
committed by GitHub
parent 3fc7f1880f
commit c4d266e94d
7 changed files with 312 additions and 154 deletions
+3 -1
View File
@@ -11,6 +11,7 @@ use awebframework::{
prelude::*,
response::IntoResponse,
routing::BoxRoute,
service::ServiceExt,
};
use bytes::Bytes;
use http::StatusCode;
@@ -53,7 +54,8 @@ async fn main() {
.into_inner(),
)
// Handle errors from middleware
.handle_error(handle_error);
.handle_error(handle_error)
.check_infallible();
// Run our app with hyper
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));