[Feature Request] Routing with decorators
See original GitHub issueI have recently started developing an application with starlette. But after working with Flask I kinda missed the routing with decorators. I wondered if it would be possible to create a decorator similar to Flask for routes. Starlette allows to add routes with Starlette.add_route
. If you combine this with the parameters given in Flask’s implementation (args: url, kwargs: method(s)) it shouldn’t be impossible. Is there a reason against such a implementation of routing? And if not could this be implemented to make routing easier, please.
Regards, Cobalt
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top Results From Across the Web
ExpressJS routing with Decorators, Dependency Injection and ...
The goal of this article is to help to build out-of-box solutions with Node.js, TS to define routing using decorators over the traditional...
Read more >routing-decorators - npm
This project is trying to achieve to provide Angular-like annotations for using the express framework. Featurelist. This is a list of all features...
Read more >How to solve REST API routing problem with decorators?
We'll be using Method Decorators to develop routesDecorator. Method Decorators: A Method Decorator is declared just before a method declaration.
Read more >View Decorators — Flask Documentation (2.2.x)
The route() decorator is the one you probably used already. But there are use cases for implementing your own decorator. For instance, imagine...
Read more >Advanced patterns for views and routing - Explore Flask
When a decorated function is called, the decorator is called instead. The decorator can then take action, modify the arguments, halt execution or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@tomchristie I understand your point. The route decorators has allowed me to transition from Flask to Starlette with very little overhead. I’d hate to see that feature deprecated but I understand that users can write their own decorator system to adopt that pattern. Tough call though.
as @hyperking said:
That is exactly what I have done. decoRouter brings back this functionality for those who want it. Check it out and let me know what you think!