-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Grouped/named routes feature request #497
Comments
Also 👍 if it's possible to set the same |
I'm facing the same need, I'd like to add the same guard to an entire set of routes rather than to every route starting with a common path. I'm curious if anyone has an elegant workaround at this point. |
If you simply want to ask Rocket for information on a set of routes, you can group them into a variable yourself: let these_routes = routes![a, b, c, d];
for route in these_routes {
// get info on routes
} If you want to ask questions later, you can put a struct RouteMap(HashMap<&'static str, Vec<Route>>);
fn main() {
let mut map = HashMap::new();
let these_routes = routes![a, b, c, d];
map.insert("these_routes", these_routes.clone());
rocket.mount("/", these_routes).manage(RouteMap(map)).launch();
}
#[get("/")]
fn map(routes: State<RouteMap>) { .. } You can, of course, wrap this into a more elegant API if you'll be using it often. @ourhut If we implement #749, such a thing would be possible elegantly. Because the initial request is possible outside of Rocket and the follow-up should be possible by solving another issue, I'm closing this out. |
I have a feature request for grouped/named routes.
This could be used to ask rocket for the routes(their paths, contenttype, request type, ...) with some identifier.
Or maybe it could be useful to set some guard on an entire group?
In my head it could look like this:
The text was updated successfully, but these errors were encountered: