diff options
author | Loïc Hoguin <[email protected]> | 2014-06-25 11:23:58 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2014-06-25 11:23:58 +0200 |
commit | fd3c40c7ee7d5efdd75481876e457e723e4b4e20 (patch) | |
tree | bbe0880196f81daa29d43954b2e774810353c108 /guide/hooks.md | |
parent | 642630fea10490e3bbe214652142c51c7787de46 (diff) | |
download | cowboy-fd3c40c7ee7d5efdd75481876e457e723e4b4e20.tar.gz cowboy-fd3c40c7ee7d5efdd75481876e457e723e4b4e20.tar.bz2 cowboy-fd3c40c7ee7d5efdd75481876e457e723e4b4e20.zip |
Wrap-up the user guide
Diffstat (limited to 'guide/hooks.md')
-rw-r--r-- | guide/hooks.md | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/guide/hooks.md b/guide/hooks.md index d7e6c72..b2e0c50 100644 --- a/guide/hooks.md +++ b/guide/hooks.md @@ -1,8 +1,12 @@ Hooks ===== -On request ----------- +Cowboy provides two hooks. `onrequest` is called once the request +line and headers have been received. `onresponse` is called just +before sending the response. + +Onrequest +--------- The `onrequest` hook is called as soon as Cowboy finishes fetching the request headers. It occurs before any other processing, including @@ -39,8 +43,8 @@ debug_hook(Req) -> Make sure to always return the last request object obtained. -On response ------------ +Onresponse +---------- The `onresponse` hook is called right before sending the response to the socket. It can be used for the purposes of logging responses, @@ -51,7 +55,7 @@ Note that like the `onrequest` hook, this function MUST NOT crash. Cowboy may or may not send a reply if this function crashes. If a reply is sent, the hook MUST explicitly provide all headers that are needed. -You can specify the `onresponse` hook when creating the listener also. +You can specify the `onresponse` hook when creating the listener. ``` erlang cowboy:start_http(my_http_listener, 100, |