Skip to content
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

modular/composable APIs #1047

Closed
alyti opened this issue Jul 7, 2019 · 2 comments
Closed

modular/composable APIs #1047

alyti opened this issue Jul 7, 2019 · 2 comments
Labels
request Request for new functionality

Comments

@alyti
Copy link

alyti commented Jul 7, 2019

Feature Request

I would like to see some way to have nested mounting / sub-routers in Rocket.
I am coming from Go and there I normally use chi for my app's server, I love it's modular sub-router implementation and was a bit hampered by it's lack in Rocket when I tried to work on my project.

I've looked over all the other issues that are even remotely related to this and none suggested this before, but if I missed something please let me know!

1. Why you believe this feature is necessary.

It makes developing larger applications easier. As of right now you can only return a vector of routes from another function, this is pretty flat and for any moderately large API will result in having a huge cluster.

2. A convincing use-case for this feature.

Modular router means you can have as many sub-routers as you need instead of clustering a ton of registrations in a single place everything.

3. Why this feature can't or shouldn't exist outside of Rocket.

This change requires modifying how the router operates.

@jebrosen
Copy link
Collaborator

jebrosen commented Jul 7, 2019

I see at least a few reasons to want this:

  1. Adding some kind of guard or handler to multiple routes at once: "Everything under /admin should run this code" or "this set of routes should all include the path and parameter /users/{id}".
    Something like this was mentioned in Grouped/named routes feature request #497.
  2. Mounting multiple routes at the same place without writing it on every route: "These routes defined at /users and /pages should be mapped to /admin/users and /admin/pages." This can be done by mount()ing a set of routes under a path, but only one level.

I think option 1 would require some significant changes/additions to Rocket, and 2 could be extended to work in a nested manner by making use of Route::set_uri.

It would be helpful to see some of the code you are writing now and the code you would like to be able to write instead.

@jebrosen jebrosen added the request Request for new functionality label Jul 7, 2019
@alyti
Copy link
Author

alyti commented Jul 16, 2019

I've since opted to switch from Rocket to Gotham since it already has this behavior in form of route delegation, I'll go ahead and close the issue now, but feel free to re-open if necessary.

@alyti alyti closed this as completed Jul 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
request Request for new functionality
Projects
None yet
Development

No branches or pull requests

2 participants