Document the `request.app` property.

* Mention it in the Request documentation
* Mention it in the Application documentation in the context of
  accessing the application state
This commit is contained in:
Liam O'Boyle 2019-08-28 08:11:03 +10:00
parent ce2883e28d
commit 0e75f9f2b8
2 changed files with 5 additions and 1 deletions

View File

@ -80,7 +80,7 @@ exceptions that occur within the application:
### Storing state on the app instance
You can store arbitrary extra state on the application instance, using the
generic `app.state` attribute.
generic `app.state` attribute. This can then be accessed in middleware or endpoints via `request.app`.
For example:

View File

@ -140,6 +140,10 @@ filename = form["upload_file"].filename
contents = await form["upload_file"].read()
```
#### Application
The originating Starlette application can be accessed via `request.app`.
#### Other state
If you want to store additional information on the request you can do so