From bf4efb448832641bceea00dfe28cba88bb14ea46 Mon Sep 17 00:00:00 2001 From: Aldo Mateli Date: Sun, 22 Dec 2024 13:10:39 +0000 Subject: [PATCH] wip --- docs/pages/integrations/fastapi.md | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/docs/pages/integrations/fastapi.md b/docs/pages/integrations/fastapi.md index fb87fb3..f3a74c7 100644 --- a/docs/pages/integrations/fastapi.md +++ b/docs/pages/integrations/fastapi.md @@ -46,16 +46,6 @@ To help with migration, it is possible to use Wireup in FastAPI depends or anywhere you have a reference to the FastAPI application instance. -```python -async def some_route_or_fastapi_dependency( - greeter: Annotated[GreeterService, WireupService(GreeterService)], - foo_param: Annotated[str, WireupParameter("foo")], - foo_foo: Annotated[str, WireupExpr("${foo}-${foo}")], - container: Annotated[DependencyContainer, WireupContainer()], -): ... -``` - - If you're not storing the container in a variable somewhere, you can get a reference to it by using the `wireup.integration.fastapi.get_container` function. @@ -79,6 +69,18 @@ async def example_dependency(request: Request, other_dependency: Annotated[X, De ... ``` +The integration also provides some FastAPI Depends functions you can use directly that perform some operation +with the container. + +```python +async def some_fastapi_dependency( + greeter: Annotated[GreeterService, WireupService(GreeterService)], + foo_param: Annotated[str, WireupParameter("foo")], + foo_foo: Annotated[str, WireupExpr("${foo}-${foo}")], + container: Annotated[DependencyContainer, WireupContainer()], +): ... +``` + ### FastAPI request A key feature of the integration is to expose `fastapi.Request` and `starlette.requests.Request` objects in wireup.