Closed BenJeau closed 2 years ago
Not sure if this should be a part of sanic_ext
or sanic
Another way would be to list, at the beginning when starting the server, all the routes and their route names, and then warning on the duplicate ones (I would personally love this since you sometimes don't know which routes/handlers actually get registered when you have a big codebase with nested blueprints) - unless that's already a feature
This is a known thing. We will probably start with a warning and eventually raise an error for duplicate named routes. It will probably be a part of sanic-routing
in finalize
.
I am going to solve this in app startup so we can provide a deprecation notice consistently.
Is your feature request related to a problem? Please describe your use case. Just spent a good amount of time trying to figure why injections were not working on certain routes, after digging the code a bit more, it seemed like when the route names are the same, the injection will overwrite the value in the
SignatureRegistry
Describe the solution you'd like Something like this, showing which route names are already in the registry and maybe also mentioning which route have injections (although that last one would be for debugging purposes, maybe have a toggle?):
For the warning, I've just added a simple check here:
https://github.com/sanic-org/sanic-ext/blob/b65cd9f28c8d1e6ee0aad91685bfb84fc4925ac6/sanic_ext/extensions/injection/registry.py#L54-L59
With