Skip to content

Commit

Permalink
Merge pull request aio-libs#578 from sloria/signal-docs
Browse files Browse the repository at this point in the history
Improve documentation for signals
  • Loading branch information
asvetlov committed Oct 21, 2015
2 parents 0da8f92 + 9222013 commit 1741564
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions docs/web.rst
Original file line number Diff line number Diff line change
Expand Up @@ -606,19 +606,22 @@ Signals
.. versionadded:: 0.18
While :ref:`midlewares <aiohttp-web-middlewares>` gives very powerful
While :ref:`middlewares <aiohttp-web-middlewares>` gives very powerful
tool for customizing :ref:`web handler<aiohttp-web-handler>`
processing we need another machinery also called signals.
For example middleware may change HTTP headers for *unprepared* response only
(see :meth:`aiohttp.web.StreamResponse.prepare`).
But sometimes we need a hook for changing HTTP headers for streamed
responses and websockets. That can be done by subsribing on
responses and websockets. That can be done by subscribing on
:attr:`aiohttp.web.Application.on_response_prepare` signal::
async def on_prepare(request, response):
response.headers['My-Header'] = 'value'
async def on_prepare(request, response):
response.headers['My-Header'] = 'value'
app.on_response_prepare.append(on_prepare)
Signal handlers should not return a value but may modify incoming
mutable parameters.
Expand Down

0 comments on commit 1741564

Please sign in to comment.