Skip to content

How to define "endpoint" without using "decorator syntax" ? #1624

Closed Answered by provinzkraut
4n1qz5skwv asked this question in Q&A
Discussion options

You must be logged in to vote

The issue you're having is that you want to do this

This way we can have central control on the route connections and easy to configure.

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

async def mail_page(request: Request):
    ...

app = Starlette(routes=[Route(path='/{token:uuid}', endpoint=mail_page, methods=['GET'], name='mail')])

is this Litestar app:

@get("/{token:uuid}", name="mail")
async def mail_page(request: Request):
    ...

app = Litestar(route_handlers=[mail_page])

So to answer your question: You can't. Decorators are…

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@provinzkraut
Comment options

@4n1qz5skwv

This comment was marked as disruptive content.

@provinzkraut
Comment options

Answer selected by 4n1qz5skwv
@4n1qz5skwv

This comment was marked as disruptive content.

@provinzkraut
Comment options

@4n1qz5skwv

This comment was marked as disruptive content.

@Goldziher
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants