FastAPI Integration API¶
configure(app: FastAPI, container: Container) -> None¶
Attach the container to app.state.container and add RequestScopeMiddleware.
Inject(cls: type[T]) -> T¶
Returns a FastAPI Depends() that resolves cls from the app's global container.
ScopedInject(cls: type[T]) -> T¶
Returns a FastAPI Depends() that resolves cls from the request-scoped container.
RequestScopeMiddleware¶
Added automatically by configure(). Creates a ScopedContainer per request at request.state.scope.