FastAPI
wireup.integration.fastapi¶
Classes¶
Functions¶
fastapi_request_factory()
¶
Provide the current FastAPI request as a dependency.
Note that this requires the Wireup-FastAPI integration to be set up.
fastapi_websocket_factory()
¶
Provide the current FastAPI WebSocket as a dependency.
Note that this requires the Wireup-FastAPI integration to be set up.
get_app_container(app)
¶
Return the container associated with the given FastAPI application.
get_request_container()
¶
When inside a request, returns the scoped container instance handling the current request.
setup(container, app, *, class_based_handlers=None, middleware_mode=False)
¶
Integrate Wireup with FastAPI.
Setup performs the following: * Injects dependencies into HTTP and WebSocket routes. * Closes the Wireup container upon app shutdown using the lifespan context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
container |
AsyncContainer
|
An async container created via |
required |
app |
FastAPI
|
The FastAPI application to integrate with. All routes must have been added to the app before this call. |
required |
class_based_handlers |
Optional[Iterable[Type[_ClassBasedHandlersProtocol]]]
|
A list of class-based handlers to register. These classes must have a |
None
|
middleware_mode |
bool
|
If True, the container is exposed in fastapi middleware. Note, for this to work correctly, there should be no more middleware added after the call to this function. For more details, visit: https://maldoinc.github.io/wireup/latest/integrations/fastapi/ |
False
|