Hi, I'm creating an HTTP router based on hyper, https://github.com/giraffate/keiro. Currently, Handler is like fn index(req: Request) -> Result<Response, Box<dyn Error + Send + Sync>
:
#[tokio::main]
async fn main() {
let mut router = Router::new();
router.get("/", index);
let addr = SocketAddr::from(([0, 0, 0, 0], 8080));
Server::bind(&addr)
.serve(router.into_service())
.await
.unwrap();
}
async fn index(_req: Request<Body>) -> Result<Response<Body>, Box<dyn Error + Send + Sync>> {
Ok(Response::new(Body::from("Hello keiro!")))
}
But I want to be able to specify any error type in each app using this router, for example fn index(req: Request) -> Result<Response, Infallible>
and fn index(req: Request) -> Result<Response, hyper::Error>
. I'm trying to implement the error type as generics in https://github.com/giraffate/keiro/tree/error_type, but the compile error happens like this https://github.com/giraffate/keiro/pull/1.
Can anyone help me with how to solve this? Of course, any feedback is welcome, even if it's not related to this!