-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
There is no way to 'del_route' #752
Comments
Please provide your use case for route deletion. |
I thought about it again and you are probably right. Thank you for the quick response :) |
I know this was closed a long time ago, but I have actually a use case where adding/removing routes and subapps can be useful. In particular, having the ability to add/remove routes/subapps can be an easy implementation for premium/paid features on a website. Imagine you have a basic service free to use, but like many portals you provide more or improved functionalities under payment/subscription. The additional/enhanced features might well be complete subapp or particular routes added or removed when the payment is done. |
@espositofulvio The more realistic case is dynamic runtime web app configuration based on microservices-driven environment. But this case would require more advanced than UrlDispatcher router, which could implement required interface. |
@kxepal I thought about that, but I'd rather add and remove features completely instead of relying on an authorization mechanism. It also means less work, leaner websites, less surface for errors. This way I could also concoct a way to add features at runtime without server restarting, by means of an interface panel that can scan a directory for new packages which can dynamically add themselves to the application. |
I suggest making a subapp with custom router. |
Is there no chance of this being added to I have a use-case for this; I'm writing a dynamically-configurable CMS with a plugin system, restarting the entire node isn't really a nice way to remove a set of routes when a plugin is unloaded, so it would be nice if I've been attempting to remove routes from the router myself, but coming up with unique identifiers (and later retrieving them after |
It's really complex problem.
Deletion should do the reverse with dropping resource if it handles no routes anymore. How Django, Flask or other Python HTTP framework handles it? I don't recall such functionality. |
Most frameworks don't seem to handle it unfortunately. Nobody appears to know why, though. The method I'm currently using is unique to my own application, since I have my own route registration system (so that we know what plugins own what routes), so I'm using the module/class name as a unique identifier and searching the router for routes with that identifier. It's working for now, I just feel like it's a poor way to do it. |
I don't think any of those frameworks do something similar but it could be really interesting when add_domain (or add_subdomain) will be added to aiohttp (and I hope the relative remove_[sub]domain] too), multi-site and multi-tenancy systems would be very easy to implement. |
In my mind route table should be frozen before starting serving the application, otherwise it opens a can of worms. |
In a sense, I can definitely see why one would want that. That said, it's just really not something you can do with a microkernel architecture, especially not if you want it to be configured on the fly. I don't see any particular harm in adding the feature with a documented warning though, if you really feel like it'll mess people up. |
Well, you can try to make a Pull Request with proposed implementation as subject for concrete discussion. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs. |
I sometimes want to remove a route from my web app, but it seems like there is no way to do this from the current app.router interface (UrlDispatcher in web_urldispatcher.py)
For example, I might do something like:
And then later in my program remove this route, like this:
Is there a way to do this, or is this some kind of bad form and I should find another solution?
Thank you for your help, and also thank you for this great library :)
The text was updated successfully, but these errors were encountered: