diff options
author | Loïc Hoguin <[email protected]> | 2017-07-19 19:04:48 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2017-07-19 19:04:48 +0200 |
commit | 381a193626a94430add700a108e7d9b6fa5babec (patch) | |
tree | fa640a7c5270c29d2626413d124075202599fe69 | |
parent | e7a65406a7e429a6fb46465fd4a9a0c3d66d442a (diff) | |
download | cowboy-381a193626a94430add700a108e7d9b6fa5babec.tar.gz cowboy-381a193626a94430add700a108e7d9b6fa5babec.tar.bz2 cowboy-381a193626a94430add700a108e7d9b6fa5babec.zip |
Remove hooks from the user guide
They're gone!
-rw-r--r-- | doc/src/guide/book.asciidoc | 2 | ||||
-rw-r--r-- | doc/src/guide/hooks.asciidoc | 46 | ||||
-rw-r--r-- | doc/src/guide/streams.asciidoc | 1 |
3 files changed, 0 insertions, 49 deletions
diff --git a/doc/src/guide/book.asciidoc b/doc/src/guide/book.asciidoc index 2c1c22e..063560e 100644 --- a/doc/src/guide/book.asciidoc +++ b/doc/src/guide/book.asciidoc @@ -96,6 +96,4 @@ include::architecture.asciidoc[Architecture] include::broken_clients.asciidoc[Dealing with broken clients] -include::hooks.asciidoc[Hooks] - include::overview.asciidoc[Overview] diff --git a/doc/src/guide/hooks.asciidoc b/doc/src/guide/hooks.asciidoc deleted file mode 100644 index fc79f8a..0000000 --- a/doc/src/guide/hooks.asciidoc +++ /dev/null @@ -1,46 +0,0 @@ -[[hooks]] -== Hooks - -Hooks allow the user to customize Cowboy's behavior during specific -operations. - -=== Onresponse - -The `onresponse` hook is called right before sending the response -to the socket. It can be used for the purposes of logging responses, -or for modifying the response headers or body. The best example is -providing custom error pages. - -Note that 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. - -[source,erlang] ----- -cowboy:start_http(my_http_listener, 100, - [{port, 8080}], - [ - {env, [{dispatch, Dispatch}]}, - {onresponse, fun ?MODULE:custom_404_hook/4} - ] -). ----- - -The following hook function will provide a custom body for 404 errors -when it has not been provided before, and will let Cowboy proceed with -the default response otherwise. - -[source,erlang] ----- -custom_404_hook(404, Headers, <<>>, Req) -> - Body = <<"404 Not Found.">>, - Headers2 = lists:keyreplace(<<"content-length">>, 1, Headers, - {<<"content-length">>, integer_to_list(byte_size(Body))}), - cowboy_req:reply(404, Headers2, Body, Req); -custom_404_hook(_, _, _, Req) -> - Req. ----- - -Again, make sure to always return the last request object obtained. diff --git a/doc/src/guide/streams.asciidoc b/doc/src/guide/streams.asciidoc index 243e581..a20f748 100644 --- a/doc/src/guide/streams.asciidoc +++ b/doc/src/guide/streams.asciidoc @@ -11,5 +11,4 @@ pre-release. Streams are meant to replace hooks. The relevant chapters for Cowboy 1.0 were: -* xref:hooks[Hooks] * xref:broken_clients[Dealing with broken clients] |