From 0e75f9f2b8454f84d86d6196131e85dadc465583 Mon Sep 17 00:00:00 2001 From: Liam O'Boyle Date: Wed, 28 Aug 2019 08:11:03 +1000 Subject: [PATCH] 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 --- docs/applications.md | 2 +- docs/requests.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/applications.md b/docs/applications.md index e19928f5..5c30365f 100644 --- a/docs/applications.md +++ b/docs/applications.md @@ -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: diff --git a/docs/requests.md b/docs/requests.md index 5c9caa61..f0ffc66b 100644 --- a/docs/requests.md +++ b/docs/requests.md @@ -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