question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature Request] Routing with decorators

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
hyperkingcommented, Sep 20, 2021

@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.

0reactions
MrPigsscommented, Mar 3, 2022

as @hyperking said:

users can write their own decorator system to adopt that pattern.

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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found