aboutsummaryrefslogtreecommitdiffstats
path: root/guide/hooks.md
diff options
context:
space:
mode:
Diffstat (limited to 'guide/hooks.md')
-rw-r--r--guide/hooks.md14
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,