From fd3c40c7ee7d5efdd75481876e457e723e4b4e20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 25 Jun 2014 11:23:58 +0200 Subject: Wrap-up the user guide --- guide/hooks.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'guide/hooks.md') 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, -- cgit v1.2.3