Merge branch '1.0.x' into 1.1.x

This commit is contained in:
David Lord 2019-09-23 08:38:11 -07:00
commit 746d9181d7
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
9 changed files with 71 additions and 71 deletions

View file

@ -867,16 +867,22 @@ docs for more information.
Read more on :ref:`application-errors`.
Hooking in WSGI Middlewares
---------------------------
Hooking in WSGI Middleware
--------------------------
If you want to add a WSGI middleware to your application you can wrap the
internal WSGI application. For example if you want to use one of the
middlewares from the Werkzeug package to work around bugs in lighttpd, you
can do it like this::
To add WSGI middleware to your Flask application, wrap the application's
``wsgi_app`` attribute. For example, to apply Werkzeug's
:class:`~werkzeug.middlware.proxy_fix.ProxyFix` middleware for running
behind Nginx:
from werkzeug.contrib.fixers import LighttpdCGIRootFix
app.wsgi_app = LighttpdCGIRootFix(app.wsgi_app)
.. code-block:: python
from werkzeug.middleware.proxy_fix import ProxyFix
app.wsgi_app = ProxyFix(app.wsgi_app)
Wrapping ``app.wsgi_app`` instead of ``app`` means that ``app`` still
points at your Flask application, not at the middleware, so you can
continue to use and configure ``app`` directly.
Using Flask Extensions
----------------------