Skip to content
Discussion options

You must be logged in to vote

I think I could write something similar with Axum but sadly, I don't think there is a way to use State (database pool) from extractors so I am using a middleware instead.

There is. FromRequestParts and FromRequest both have S type parameter. That is the state. So you can implement FromRequestParts<YourExactState or possibly like this https://docs.rs/axum/0.6.0-rc.5/axum/extract/struct.State.html#for-library-authors if you wanna be extra flexible.

If you wanna use a middleware you'll have to write one middleware to handle both auth schemes. There is no such thing as or for middleware.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by iTzBoboCz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants