Response Middleware¶
Response middleware are callable objects which can be used in conjunction with pulsar WsgiHandler. They must return a WsgiResponse which can be the same as the one passed to the callable or a brand new one.
Interface¶
-
class
pulsar.apps.wsgi.response.
ResponseMiddleware
[source]¶ Base class for response middlewares.
A response middleware is used by a WsgiHandler, it is a callable used to manipulate a WsgiResponse.
The focus of this class is the
execute()
method where the middleware logic is implemented.-
available
(environ, response)[source]¶ Check if this
ResponseMiddleware
can be applied to theresponse
object.Parameters: - environ – a WSGI environ dictionary.
- response – a
pulsar.apps.wsgi.wrappers.WsgiResponse
Returns: True
orFalse
.
-
execute
(environ, response)[source]¶ Manipulate response, called only if the
available()
method returnsTrue
.
-
GZip Middleware¶
-
class
pulsar.apps.wsgi.response.
GZipMiddleware
(min_length=200)[source]¶ A
ResponseMiddleware
for compressing content if the request allows gzip compression. It sets the Vary header accordingly.The compression implementation is from http://jython.xhaus.com/http-compression-in-python-and-jython