one way to be compatible with middleware through async def dispatch(req: Request, call_next) is to make a factory function that is what that get sent to fastapi for deps resolution with the signature of def <some-name>(<some-generated-req-param-name>: Request): ..., then in the body of asyc def dispatch, user can do something like shield_result = await some_shield(request) and do whatever they want with the shield_result and call_next.
one way to be compatible with middleware through
async def dispatch(req: Request, call_next)is to make a factory function that is what that get sent to fastapi for deps resolution with the signature ofdef <some-name>(<some-generated-req-param-name>: Request): ..., then in the body ofasyc def dispatch, user can do something likeshield_result = await some_shield(request)and do whatever they want with theshield_resultandcall_next.