Asynchronous Middleware¶
A WSGI Middleware is a function or callable object similar to a
WSGI application handlers
with the only difference that it can return nothing (None
).
Middleware can be used in conjunction with a WsgiHandler or any other handler which iterate through a list of middleware in a similar way (for example django wsgi handler).
Important
An asynchronous WSGI middleware is a callable accepting a WSGI
environ
and start_response
as the only input parameters and
it must returns an asynchronous iterator
or nothing.
The two most important wsgi middleware in pulsar are:
- the Router for serving dynamic web applications
- the MediaRouter for serving static files
In addition, pulsar provides with the following four middlewares which don’t serve requests, instead they perform initialisation and sanity checks.
Clean path¶
Authorization¶
Parse the
HTTP_AUTHORIZATION
key in theenviron
.If available, set the
http.authorization
key inenviron
with the result obtained fromparse_authorization_header()
function.
Wait for request body¶
-
pulsar.apps.wsgi.middleware.
wait_for_body_middleware
(environ, start_response=None)[source]¶ Use this middleware to wait for the full body.
This middleware wait for the full body to be received before letting other middleware to be processed.
Useful when using synchronous web-frameworks such as django.