Rational
As we’d like to make routes modifiable by implementors we need to put them in Pool in order to reuse the patterns people already know of register object by their __name__ in the pool and the possibility to override it in custom modules.
Another issue with the current route design is that they are available even when the module is not activated. Accessing them would result in an error but it leaks some information that might be valuable.
Proposal
Our proposal is to add routes into the pool.
- Adding a new type in the Pool:
route - Objects will be registered in the Pool by their
__name__ - Just like we register methods in
__rpc__, those object will contain a mapping named__routes__between a couple (endpoint, HTTP Verb) and aRouteobject - This
Routeobject will represent:- The
nameof the method to call when accessing the route - A list of decorators to apply on the method (eg:
auth_required, etc).
- The
- The URL will be composed as follow:
/<database>/<__name__>/<endpoint>
At the end of the initialization of a database pool a process will define in Werkzeug all the available routes.
It might happen that a request to a route will be the event that initialize the pool (and thus the routes are not known yet), in this case instead of raising a 404, we should initialize the pool and then replay the request.