-
-
Notifications
You must be signed in to change notification settings - Fork 342
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
Enhancement: default handlers names for url_for use #2892
Comments
A few things to think about:
# a.py
@get("/a")
def get_handler() -> A:
... # b.py
@get("/b")
def get_handler() -> B:
... # app.py
from a import get_handler as get_a
from b import get_handler as get_b
app = Litestar([get_a, get_b])
What if we built a name from the handler method/func that included the module path and the |
Also, if a handler is registered multiple times |
What about "module.function" |
Unfortunately it's not that easy, because it would mean that class SomeController(Controller):
@get()
def handler(self) -> str:
... and @get()
def handler() -> str:
... would produce the same name. The pattern @peterschutt suggested in this comment, using |
Summary
Currently if in a template I want t o do:
<a href="{{ url_for("login_get_name") }}"></a>
then in litestar I have to explicitely use the name kwarg in the handler's decorator:
I'd like to be able to do
<a href="{{ url_for("login_get_func") }}"></a>
with:currently a 500 is raised
litestar.exceptions.http_exceptions.NoRouteMatchFoundException: 500: Route login_get_func can not be found
Basic Example
No response
Drawbacks and Impact
No response
Unresolved questions
No response
Note
While we are open for sponsoring on GitHub Sponsors and
OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.
Check out all issues funded or available for funding on our Polar.sh dashboard
The text was updated successfully, but these errors were encountered: