Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
maldoinc committed Dec 22, 2024
1 parent 1adcaa9 commit bf4efb4
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions docs/pages/integrations/fastapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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.
Expand Down

0 comments on commit bf4efb4

Please sign in to comment.