http-rs / tide

Fast and friendly HTTP server framework for async Rust
https://docs.rs/tide
Apache License 2.0
5.07k stars 321 forks source link

Route introspection? #882

Open yaleman opened 2 years ago

yaleman commented 2 years ago

Is there a way to do this - I'd like to be able to do something similar to #101 and pull information from the server as built, but I can't find any interface to do so?

jbr commented 2 years ago

This is not currently possible, but is closer to possible on main than the latest release. You'd need to iterate over the routefinder routers, which are not currently publicly exposed

pictographer commented 2 years ago

In my project, I'm defining routes in a TOML file along with documentation, error messages, and parameter types.

As a workaround for lack of access to the route finder's internal state, I configure Tide with the minimum number of catch-all routes and then will use the routefinder crate myself. It's a bit redundant because each route is parsed twice, but Tide's parsing is just a minimal wildcard.

I've gotta' say, Tide is pretty great for how few lines of code it is.