How to define "endpoint" without using "decorator syntax" ? #1624
-
An starlette example, async def mail_page(request: Request):
...
app = Starlette(routes=[
Mount(root_path, routes=[
Route(path='/{token:uuid}', endpoint=mail_page, methods=['GET','POST'], name='mail'),
])
]
) This way we can have central control on the route connections and easy to configure. |
Beta Was this translation helpful? Give feedback.
Answered by
provinzkraut
May 7, 2023
Replies: 1 comment 10 replies
-
This is already how the decorators work. They don’t register a route handler, they just define it. They’re registered by passing it to the app, exactly like oh your example. i recommend you read the documentation: https://docs.litestar.dev/latest/ |
Beta Was this translation helpful? Give feedback.
10 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The issue you're having is that you want to do this
but arrived at the conclusion that the way to achieve it is to not use decorators.
This conclusion however is wrong, since what you want is already how Litestar works.
The equivalent of this Starlette app
is this Litestar app:
So to answer your question: You can't. Decorators are…