From 8459bebceb9533948193774371cbd9fd571b78ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 16 Oct 2019 09:48:31 +0200 Subject: Cowboy 2.7.0 --- docs/en/cowboy/2.5/guide/handlers/index.html | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'docs/en/cowboy/2.5/guide/handlers/index.html') diff --git a/docs/en/cowboy/2.5/guide/handlers/index.html b/docs/en/cowboy/2.5/guide/handlers/index.html index d97992b1..0ac0d42c 100644 --- a/docs/en/cowboy/2.5/guide/handlers/index.html +++ b/docs/en/cowboy/2.5/guide/handlers/index.html @@ -67,7 +67,7 @@

The most basic handler in Cowboy implements the mandatory init/2 callback, manipulates the request, optionally sends a response and then returns.

This callback receives the Req object and the initial state defined in the router configuration.

A handler that does nothing would look like this:

-
@@ -76,7 +76,7 @@ http://www.gnu.org/software/src-highlite -->

Despite sending no reply, a 204 No Content response will be sent to the client, as Cowboy makes sure that a response is sent for every request.

We need to use the Req object to reply.

-
@@ -93,7 +93,7 @@ http://www.gnu.org/software/src-highlite -->

The init/2 callback can also be used to inform Cowboy that this is a different kind of handler and that Cowboy should switch to it. To do this you simply need to return the module name of the handler type you want to switch to.

Cowboy comes with three handler types you can switch to: cowboy_rest, cowboy_websocket and cowboy_loop. In addition to those you can define your own handler types.

Switching is simple. Instead of returning ok, you simply return the name of the handler type you want to use. The following snippet switches to a Websocket handler:

-
@@ -102,7 +102,7 @@ http://www.gnu.org/software/src-highlite -->

Cleaning up

All handler types provide the optional terminate/3 callback.

-
@@ -169,6 +169,8 @@ http://www.gnu.org/software/src-highlite --> +
  • 2.7
  • +
  • 2.6
  • 2.5
  • -- cgit v1.2.3