With FastAPI's APIRouter
, I know you can pass a dependency through the dependencies
parameter. Every example I see though has a dependency that doesn't return anything. I've been diving through the code, but I'm guessing I'm not understanding how to do what I want, and would be fine knowing that is not possible; I can always add the dependency to every route.
my_module = APIRouter(prefix="/abc", dependencies=[Depends(get_permissions)])
@my_module.get('/')
def route_1(permissions: Permissions):
pass
@my_module.get('/a')
def route_2(permissions: Permissions):
pass
I want to do something like this where the permissions are retrieved via get_permissions
and injected into each route.