Hyper.rs nested routes?

Is there a way to nest routes with hyper.rs?

I want to do something like:

( "/counter") -> counter_handler


  (Method::GEt, "/get") -> ...
  (Method::POST, "/inc") -> ...
  (Method::POST, "/dec") -> ...

As far as I recall, hyper doesn't have any router built in. You have to use one of the router crates out there, or write your own.

I literally just did something like this.

I wrote handlers to check the uri and method and return an option containing a result if it matches and none otherwise. That way I can chain the handlers together in whatever order I like.

You could also check out axum which is a lightweight framework on top of hyper that can route requests.

I know, I've used axum. I was just pointing out that it isn't really that hard to do it yourself through hyper.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.