0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-15 04:30:25 +00:00

Add {switch_handler, Module} return value to cowboy_rest

Also {switch_handler, Module, Opts}.

Allows switching to a different handler type. This is
particularly useful for processing most of the request
with cowboy_rest and then streaming the response body
using cowboy_loop.
This commit is contained in:
Loïc Hoguin 2017-11-01 16:27:26 +00:00
parent 5e88a9b394
commit 836342abb8
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764
5 changed files with 191 additions and 11 deletions

View file

@ -43,8 +43,12 @@ you need.
All callbacks take two arguments, the Req object and the State,
and return a three-element tuple of the form `{Value, Req, State}`.
All callbacks can also return `{stop, Req, State}` to stop execution
of the request.
Nearly all callbacks can also return `{stop, Req, State}` to
stop execution of the request, and
`{{switch_handler, Module}, Req, State}` or
`{{switch_handler, Module, Opts}, Req, State}` to switch to
a different handler type. The exceptions are `expires`
`generate_etag`, `last_modified` and `variances`.
The following table summarizes the callbacks and their default values.
If the callback isn't defined, then the default value will be used.