Skip to content

How to add multiple auth middlewares? #1987

Answered by provinzkraut
robertlagrant asked this question in Q&A
Discussion options

You must be logged in to vote

Middlewares already call other middlewares / ASGI apps, since they themselves are ASGI apps as well.

It usually looks something like

await self.app(scope, send, receive)

So if you were to wrap one middleware into another, you'd simply wrap these calls.

You can take a look at https://github.com/litestar-org/litestar/blob/a288fd49ec50426da146f8e9071163d5b892c335/litestar/middleware/base.py or the middlewares in https://github.com/litestar-org/litestar/tree/a288fd49ec50426da146f8e9071163d5b892c335/litestar/middleware to see how that's usually implemented.

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by JacobCoffee
Comment options

You must be logged in to vote
1 reply
@Murtagy
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
Documentation 📚 This is related to documentation
3 participants
Converted from issue

This discussion was converted from issue #1940 on July 17, 2023 07:55.