[QUESTION] Parameterized dependencies
See original GitHub issueFirst check
- I used the GitHub search to find a similar issue and didn’t find it.
- I searched the FastAPI documentation, with the integrated search.
- I already searched in Google “How to X in FastAPI” and didn’t find any information.
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!
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Advanced Dependencies - FastAPI
Let's imagine that we want to have a dependency that checks if the query parameter q contains some fixed content. But we want...
Read more >Dependency injection using parameters | F# for fun and profit
In this series, we are looking at six different approaches to dependency injection. In the first post, we looked at “dependency retention” ...
Read more >How to achieve nested parameterized dependencies? #1655
The issue here is simply that currently parameterized dependencies do not work as sub dependencies. This really limits their usability. For us ...
Read more >Use just one parameter for all dependencies instead of many?
The point is a service locator is an object that has the dependencies of other objects. The better question is, if you are...
Read more >Combining DI with constructor parameters? - Stack Overflow
Our approach is to create a factory via D.I., and the factory's Create method would then build itself out using the passed in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Solved the issue on my end, thanks for the help!
Thanks for reporting back and closing the issue 👍