FastAPI¶
Requires the fastapi extra. See FastAPI for
installation and usage.
-
imgproxykit.integrations.fastapi.add_imgproxy(app: FastAPI, client: Client, *, name: str =
'imgproxykit_client') Callable[[Request], Awaitable[Client]][source]¶ Register a client and return its FastAPI dependency.
Call while building the application, before it starts serving requests. Keep the returned callable for use with
Dependsand dependency overrides. Each application owns its clients; the dependency resolves its name against the application handling the current request.- Parameters:¶
- Return type:¶
Callable[[Request],Awaitable[Client]]- Returns:¶
An async dependency returning the registered client. URL generation remains synchronous and makes no network requests.
- Raises:¶
ValueError – If the application’s state already has this attribute.
TypeError – When the application’s state attribute does not contain a client, including when it has not been registered.