Parameterized dependencies #7776
Replies: 5 comments
-
I'm inclined to use a class dependency with an async call:
Just wanted to make sure this is the best (and possibly only) option. |
Beta Was this translation helpful? Give feedback.
-
Yep @victoraugustolls that should work. You could also create a function inside another, but I think this is probably cleaner. |
Beta Was this translation helpful? Give feedback.
-
I tried doing it this way so I don't have to instanciate 2 instances of my class but it didn't work. Any tips?
|
Beta Was this translation helpful? Give feedback.
-
Solved the issue on my end, thanks for the help! |
Beta Was this translation helpful? Give feedback.
-
Thanks for reporting back and closing the issue 👍 |
Beta Was this translation helpful? Give feedback.
-
First check
Description
How can I create an async Parameterized dependency?
I found this link but I'm not quite sure it is the best option to my use case.
I have an authentication dependency with the following signature:
async def verify_token(request: Request):
And I needed to pass a boolean as a parameter, like:
async def verify_token(request: Request, get_details: boolean = False):
So I though that the best way would be to create a class to do it, but I'm not quite sure about it.
Any thoughts about this? Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions