diff options
Diffstat (limited to 'docs')
25 files changed, 530 insertions, 230 deletions
diff --git a/docs/en/cowboy/2.0/guide/architecture/index.html b/docs/en/cowboy/2.0/guide/architecture/index.html index 67a10e88..552fa92c 100644 --- a/docs/en/cowboy/2.0/guide/architecture/index.html +++ b/docs/en/cowboy/2.0/guide/architecture/index.html @@ -127,8 +127,8 @@ only processing short-lived requests.</p></div> <nav style="margin:1em 0"> - <a style="float:left" href="https://ninenines.eu/docs/en/cowboy/2.0/guide/ws_handlers/"> - Websocket handlers + <a style="float:left" href="https://ninenines.eu/docs/en/cowboy/2.0/guide/sub_protocols/"> + Sub protocols </a> diff --git a/docs/en/cowboy/2.0/guide/broken_clients/index.html b/docs/en/cowboy/2.0/guide/broken_clients/index.html index 331dc36c..c23fba28 100644 --- a/docs/en/cowboy/2.0/guide/broken_clients/index.html +++ b/docs/en/cowboy/2.0/guide/broken_clients/index.html @@ -147,8 +147,8 @@ http://www.gnu.org/software/src-highlite --> - <a style="float:right" href="https://ninenines.eu/docs/en/cowboy/2.0/guide/middlewares/"> - Middlewares + <a style="float:right" href="https://ninenines.eu/docs/en/cowboy/2.0/guide/hooks/"> + Hooks </a> </nav> diff --git a/docs/en/cowboy/2.0/guide/flow_diagram.asciidoc b/docs/en/cowboy/2.0/guide/flow_diagram.asciidoc index 10954040..ad2110dc 100644 --- a/docs/en/cowboy/2.0/guide/flow_diagram.asciidoc +++ b/docs/en/cowboy/2.0/guide/flow_diagram.asciidoc @@ -2,3 +2,11 @@ == Flow diagram Placeholder chapter. + +Cowboy 2.0 has changed the request flow and general architecture. +You can read about the Cowboy 1.0 architecture and flow here: + +* xref:architecture[Architecture] +* xref:overview[Overview] + +This chapter will be updated in a future pre-release. diff --git a/docs/en/cowboy/2.0/guide/flow_diagram/index.html b/docs/en/cowboy/2.0/guide/flow_diagram/index.html index 25f2b799..191aa3bd 100644 --- a/docs/en/cowboy/2.0/guide/flow_diagram/index.html +++ b/docs/en/cowboy/2.0/guide/flow_diagram/index.html @@ -70,6 +70,21 @@ <h1 class="lined-header"><span>Flow diagram</span></h1> <div class="paragraph"><p>Placeholder chapter.</p></div>
+<div class="paragraph"><p>Cowboy 2.0 has changed the request flow and general architecture.
+You can read about the Cowboy 1.0 architecture and flow here:</p></div>
+<div class="ulist"><ul>
+<li>
+<p>
+<a href="../architecture">Architecture</a>
+</p>
+</li>
+<li>
+<p>
+<a href="../overview">Overview</a>
+</p>
+</li>
+</ul></div>
+<div class="paragraph"><p>This chapter will be updated in a future pre-release.</p></div>
diff --git a/docs/en/cowboy/2.0/guide/handlers.asciidoc b/docs/en/cowboy/2.0/guide/handlers.asciidoc index 88fbc21f..e073dfb6 100644 --- a/docs/en/cowboy/2.0/guide/handlers.asciidoc +++ b/docs/en/cowboy/2.0/guide/handlers.asciidoc @@ -29,9 +29,9 @@ We need to use the Req object to reply. [source,erlang] ---- init(Req0, State) -> - Req = cowboy_req:reply(200, [ - {<<"content-type">>, <<"text/plain">>} - ], <<"Hello World!">>, Req0), + Req = cowboy_req:reply(200, #{ + <<"content-type">> => <<"text/plain">> + }, <<"Hello World!">>, Req0), {ok, Req, State}. ---- @@ -81,8 +81,7 @@ xref:sub_protocols[Sub protocols] chapter. === Cleaning up -With the exception of Websocket handlers, all handler types -provide the optional `terminate/3` callback. +All handler types provide the optional `terminate/3` callback. [source,erlang] ---- diff --git a/docs/en/cowboy/2.0/guide/handlers/index.html b/docs/en/cowboy/2.0/guide/handlers/index.html index a9d21a16..f1b3649d 100644 --- a/docs/en/cowboy/2.0/guide/handlers/index.html +++ b/docs/en/cowboy/2.0/guide/handlers/index.html @@ -96,9 +96,9 @@ by Lorenzo Bettini http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #000000">init</span></span>(<span style="color: #009900">Req0</span>, <span style="color: #009900">State</span>) <span style="color: #990000">-></span>
- <span style="color: #009900">Req</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:reply</span></span>(<span style="color: #993399">200</span>, [
- {<span style="color: #990000"><<</span><span style="color: #FF0000">"content-type"</span><span style="color: #990000">>></span>, <span style="color: #990000"><<</span><span style="color: #FF0000">"text/plain"</span><span style="color: #990000">>></span>}
- ], <span style="color: #990000"><<</span><span style="color: #FF0000">"Hello World!"</span><span style="color: #990000">>></span>, <span style="color: #009900">Req0</span>),
+ <span style="color: #009900">Req</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:reply</span></span>(<span style="color: #993399">200</span>, #{
+ <span style="color: #990000"><<</span><span style="color: #FF0000">"content-type"</span><span style="color: #990000">>></span> <span style="color: #990000">=></span> <span style="color: #990000"><<</span><span style="color: #FF0000">"text/plain"</span><span style="color: #990000">>></span>
+ }, <span style="color: #990000"><<</span><span style="color: #FF0000">"Hello World!"</span><span style="color: #990000">>></span>, <span style="color: #009900">Req0</span>),
{<span style="color: #FF6600">ok</span>, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>}<span style="color: #990000">.</span></tt></pre></div></div>
<div class="paragraph"><p>Cowboy will immediately send a response when <code>cowboy:reply/4</code>
is called.</p></div>
@@ -146,8 +146,7 @@ http://www.gnu.org/software/src-highlite --> <div class="sect1">
<h2 id="_cleaning_up">Cleaning up</h2>
<div class="sectionbody">
-<div class="paragraph"><p>With the exception of Websocket handlers, all handler types
-provide the optional <code>terminate/3</code> callback.</p></div>
+<div class="paragraph"><p>All handler types provide the optional <code>terminate/3</code> callback.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
diff --git a/docs/en/cowboy/2.0/guide/hooks/index.html b/docs/en/cowboy/2.0/guide/hooks/index.html index 7f3252a2..5b1e63b2 100644 --- a/docs/en/cowboy/2.0/guide/hooks/index.html +++ b/docs/en/cowboy/2.0/guide/hooks/index.html @@ -121,12 +121,16 @@ http://www.gnu.org/software/src-highlite --> <nav style="margin:1em 0"> - <a style="float:left" href="https://ninenines.eu/docs/en/cowboy/2.0/guide/sub_protocols/"> - Sub protocols + <a style="float:left" href="https://ninenines.eu/docs/en/cowboy/2.0/guide/broken_clients/"> + Dealing with broken clients </a> + <a style="float:right" href="https://ninenines.eu/docs/en/cowboy/2.0/guide/overview/"> + Request overview + </a> + </nav> diff --git a/docs/en/cowboy/2.0/guide/index.html b/docs/en/cowboy/2.0/guide/index.html index d07f9ba6..7f0eb137 100644 --- a/docs/en/cowboy/2.0/guide/index.html +++ b/docs/en/cowboy/2.0/guide/index.html @@ -100,8 +100,6 @@ <a href="getting_started/">Getting started</a>
</p>
</li>
-</ul></div>
-<div class="ulist"><ul>
<li>
<p>
<a href="flow_diagram/">Flow diagram</a>
@@ -121,11 +119,6 @@ </li>
<li>
<p>
-<a href="streams/">Streams</a>
-</p>
-</li>
-<li>
-<p>
<a href="routing/">Routing</a>
</p>
</li>
@@ -229,45 +222,68 @@ </li>
<li>
<p>
-<a href="ws_handlers/">Handling Websocket connections</a>
+<a href="ws_handlers/">Websocket handlers</a>
</p>
</li>
</ul></div>
</div>
</div>
<div class="sect1">
-<h2 id="_internals">Internals</h2>
+<h2 id="_advanced">Advanced</h2>
<div class="sectionbody">
<div class="ulist"><ul>
<li>
<p>
-<a href="architecture/">Architecture</a>
+<a href="streams/">Streams</a>
+</p>
+</li>
+<li>
+<p>
+<a href="middlewares/">Middlewares</a>
</p>
</li>
</ul></div>
<div class="ulist"><ul>
<li>
<p>
-<a href="broken_clients/">Dealing with broken clients</a>
+<a href="sub_protocols/">Sub protocols</a>
</p>
</li>
+</ul></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_deprecated_chapters">Deprecated chapters</h2>
+<div class="sectionbody">
+</div>
+</div>
+<div class="sect1">
+<h2 id="_about_the_deprecated_chapters">About the deprecated chapters</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The following chapters were relevant in Cowboy 1.0. They have
+not been updated for Cowboy 2.0 yet. The information in these
+chapters may or may not be useful.</p></div>
+<div class="ulist"><ul>
<li>
<p>
-<a href="middlewares/">Middlewares</a>
+<a href="architecture/">Architecture</a>
</p>
</li>
<li>
<p>
-<a href="sub_protocols/">Sub protocols</a>
+<a href="broken_clients/">Dealing with broken clients</a>
</p>
</li>
-</ul></div>
-<div class="ulist"><ul>
<li>
<p>
<a href="hooks/">Hooks</a>
</p>
</li>
+<li>
+<p>
+<a href="overview/">Overview</a>
+</p>
+</li>
</ul></div>
</div>
</div>
diff --git a/docs/en/cowboy/2.0/guide/introduction.asciidoc b/docs/en/cowboy/2.0/guide/introduction.asciidoc index c9d042d3..1f9b52e4 100644 --- a/docs/en/cowboy/2.0/guide/introduction.asciidoc +++ b/docs/en/cowboy/2.0/guide/introduction.asciidoc @@ -42,7 +42,7 @@ Cowboy is developed for Erlang/OTP 19.0 and newer. Cowboy uses the ISC License. ---- -Copyright (c) 2011-2016, Loïc Hoguin <[email protected]> +Copyright (c) 2011-2017, Loïc Hoguin <[email protected]> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/docs/en/cowboy/2.0/guide/introduction/index.html b/docs/en/cowboy/2.0/guide/introduction/index.html index 5ab7823f..8e63cf1c 100644 --- a/docs/en/cowboy/2.0/guide/introduction/index.html +++ b/docs/en/cowboy/2.0/guide/introduction/index.html @@ -107,7 +107,7 @@ on other platforms.</p></div> <div class="paragraph"><p>Cowboy uses the ISC License.</p></div>
<div class="listingblock">
<div class="content">
-<pre><code>Copyright (c) 2011-2016, Loïc Hoguin <[email protected]>
+<pre><code>Copyright (c) 2011-2017, Loïc Hoguin <[email protected]>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
diff --git a/docs/en/cowboy/2.0/guide/listeners.asciidoc b/docs/en/cowboy/2.0/guide/listeners.asciidoc index 901b9220..7d5faec0 100644 --- a/docs/en/cowboy/2.0/guide/listeners.asciidoc +++ b/docs/en/cowboy/2.0/guide/listeners.asciidoc @@ -7,7 +7,7 @@ Depending on the connection handshake, one or another protocol may be used. This chapter is specific to Cowboy. Please refer to the -http://ninenines.eu/docs/en/ranch/1.2/guide/listeners/[Ranch User Guide] +http://ninenines.eu/docs/en/ranch/1.3/guide/listeners/[Ranch User Guide] for more information about listeners. Cowboy provides two types of listeners: one listening for diff --git a/docs/en/cowboy/2.0/guide/listeners/index.html b/docs/en/cowboy/2.0/guide/listeners/index.html index 8dc05c30..d4209d48 100644 --- a/docs/en/cowboy/2.0/guide/listeners/index.html +++ b/docs/en/cowboy/2.0/guide/listeners/index.html @@ -74,7 +74,7 @@ new connections. Incoming connections get handled by Cowboy. Depending on the connection handshake, one or another protocol
may be used.</p></div>
<div class="paragraph"><p>This chapter is specific to Cowboy. Please refer to the
-<a href="http://ninenines.eu/docs/en/ranch/1.2/guide/listeners/">Ranch User Guide</a>
+<a href="http://ninenines.eu/docs/en/ranch/1.3/guide/listeners/">Ranch User Guide</a>
for more information about listeners.</p></div>
<div class="paragraph"><p>Cowboy provides two types of listeners: one listening for
clear TCP connections, and one listening for secure TLS
diff --git a/docs/en/cowboy/2.0/guide/loop_handlers.asciidoc b/docs/en/cowboy/2.0/guide/loop_handlers.asciidoc index c0195ea0..2c82c530 100644 --- a/docs/en/cowboy/2.0/guide/loop_handlers.asciidoc +++ b/docs/en/cowboy/2.0/guide/loop_handlers.asciidoc @@ -16,7 +16,7 @@ most known example of such practice is known as long polling. Loop handlers can also be used for requests where a response is partially available and you need to stream the response body while the connection is open. The most known example of such -practice is known as server-sent events. +practice is server-sent events. While the same can be accomplished using plain HTTP handlers, it is recommended to use loop handlers because they are well-tested @@ -66,7 +66,7 @@ message otherwise. [source,erlang] ---- info({reply, Body}, Req, State) -> - cowboy_req:reply(200, [], Body, Req), + cowboy_req:reply(200, #{}, Body, Req), {stop, Req, State}; info(_Msg, Req, State) -> {ok, Req, State, hibernate}. @@ -96,19 +96,19 @@ This can be done by initiating a chunked reply in the every time a message is received. The following snippet does exactly that. As you can see -a chunk is sent every time a `chunk` message is received, +a chunk is sent every time an `event` message is received, and the loop is stopped by sending an `eof` message. [source,erlang] ---- init(Req, State) -> - Req2 = cowboy_req:chunked_reply(200, [], Req), + Req2 = cowboy_req:stream_reply(200, Req), {cowboy_loop, Req2, State}. info(eof, Req, State) -> {stop, Req, State}; -info({chunk, Chunk}, Req, State) -> - cowboy_req:chunk(Chunk, Req), +info({event, Data}, Req, State) -> + cowboy_req:stream_body(Data, nofin, Req), {ok, Req, State}; info(_Msg, Req, State) -> {ok, Req, State}. @@ -125,6 +125,9 @@ for general instructions about cleaning up. === Timeout +Note that this feature currently does not work. It will be +brought back in a future 2.0 pre-release. + By default Cowboy will not attempt to close the connection if there is no activity from the client. This is not always desirable, which is why you can set a timeout. Cowboy will diff --git a/docs/en/cowboy/2.0/guide/loop_handlers/index.html b/docs/en/cowboy/2.0/guide/loop_handlers/index.html index 64dc4b31..aec5721e 100644 --- a/docs/en/cowboy/2.0/guide/loop_handlers/index.html +++ b/docs/en/cowboy/2.0/guide/loop_handlers/index.html @@ -80,7 +80,7 @@ most known example of such practice is known as long polling.</p></div> <div class="paragraph"><p>Loop handlers can also be used for requests where a response is
partially available and you need to stream the response body
while the connection is open. The most known example of such
-practice is known as server-sent events.</p></div>
+practice is server-sent events.</p></div>
<div class="paragraph"><p>While the same can be accomplished using plain HTTP handlers,
it is recommended to use loop handlers because they are well-tested
and allow using built-in features like hibernation and timeouts.</p></div>
@@ -131,7 +131,7 @@ by Lorenzo Bettini http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #000000">info</span></span>({<span style="color: #FF6600">reply</span>, <span style="color: #009900">Body</span>}, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>) <span style="color: #990000">-></span>
- <span style="font-weight: bold"><span style="color: #000000">cowboy_req:reply</span></span>(<span style="color: #993399">200</span>, [], <span style="color: #009900">Body</span>, <span style="color: #009900">Req</span>),
+ <span style="font-weight: bold"><span style="color: #000000">cowboy_req:reply</span></span>(<span style="color: #993399">200</span>, #{}, <span style="color: #009900">Body</span>, <span style="color: #009900">Req</span>),
{<span style="color: #FF6600">stop</span>, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>};
<span style="font-weight: bold"><span style="color: #000000">info</span></span>(<span style="color: #009900">_Msg</span>, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>) <span style="color: #990000">-></span>
{<span style="color: #FF6600">ok</span>, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>, <span style="color: #FF6600">hibernate</span>}<span style="color: #990000">.</span></tt></pre></div></div>
@@ -156,7 +156,7 @@ This can be done by initiating a chunked reply in the <code>init/2</code> callback and then using <code>cowboy_req:chunk/2</code>
every time a message is received.</p></div>
<div class="paragraph"><p>The following snippet does exactly that. As you can see
-a chunk is sent every time a <code>chunk</code> message is received,
+a chunk is sent every time an <code>event</code> message is received,
and the loop is stopped by sending an <code>eof</code> message.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
@@ -164,13 +164,13 @@ by Lorenzo Bettini http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #000000">init</span></span>(<span style="color: #009900">Req</span>, <span style="color: #009900">State</span>) <span style="color: #990000">-></span>
- <span style="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:chunked_reply</span></span>(<span style="color: #993399">200</span>, [], <span style="color: #009900">Req</span>),
+ <span style="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:stream_reply</span></span>(<span style="color: #993399">200</span>, <span style="color: #009900">Req</span>),
{<span style="color: #FF6600">cowboy_loop</span>, <span style="color: #009900">Req2</span>, <span style="color: #009900">State</span>}<span style="color: #990000">.</span>
<span style="font-weight: bold"><span style="color: #000000">info</span></span>(<span style="color: #FF6600">eof</span>, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>) <span style="color: #990000">-></span>
{<span style="color: #FF6600">stop</span>, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>};
-<span style="font-weight: bold"><span style="color: #000000">info</span></span>({<span style="color: #FF6600">chunk</span>, <span style="color: #009900">Chunk</span>}, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>) <span style="color: #990000">-></span>
- <span style="font-weight: bold"><span style="color: #000000">cowboy_req:chunk</span></span>(<span style="color: #009900">Chunk</span>, <span style="color: #009900">Req</span>),
+<span style="font-weight: bold"><span style="color: #000000">info</span></span>({<span style="color: #FF6600">event</span>, <span style="color: #009900">Data</span>}, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>) <span style="color: #990000">-></span>
+ <span style="font-weight: bold"><span style="color: #000000">cowboy_req:stream_body</span></span>(<span style="color: #009900">Data</span>, <span style="color: #FF6600">nofin</span>, <span style="color: #009900">Req</span>),
{<span style="color: #FF6600">ok</span>, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>};
<span style="font-weight: bold"><span style="color: #000000">info</span></span>(<span style="color: #009900">_Msg</span>, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>) <span style="color: #990000">-></span>
{<span style="color: #FF6600">ok</span>, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>}<span style="color: #990000">.</span></tt></pre></div></div>
@@ -187,6 +187,8 @@ for general instructions about cleaning up.</p></div> <div class="sect1">
<h2 id="_timeout">Timeout</h2>
<div class="sectionbody">
+<div class="paragraph"><p>Note that this feature currently does not work. It will be
+brought back in a future 2.0 pre-release.</p></div>
<div class="paragraph"><p>By default Cowboy will not attempt to close the connection
if there is no activity from the client. This is not always
desirable, which is why you can set a timeout. Cowboy will
diff --git a/docs/en/cowboy/2.0/guide/middlewares/index.html b/docs/en/cowboy/2.0/guide/middlewares/index.html index 53a751d1..8b74b9a5 100644 --- a/docs/en/cowboy/2.0/guide/middlewares/index.html +++ b/docs/en/cowboy/2.0/guide/middlewares/index.html @@ -164,8 +164,8 @@ values. It puts the result of the request handling into <code>result</code>.</p> <nav style="margin:1em 0"> - <a style="float:left" href="https://ninenines.eu/docs/en/cowboy/2.0/guide/broken_clients/"> - Dealing with broken clients + <a style="float:left" href="https://ninenines.eu/docs/en/cowboy/2.0/guide/streams/"> + Streams </a> diff --git a/docs/en/cowboy/2.0/guide/multipart.asciidoc b/docs/en/cowboy/2.0/guide/multipart.asciidoc index 630b2107..77d263a7 100644 --- a/docs/en/cowboy/2.0/guide/multipart.asciidoc +++ b/docs/en/cowboy/2.0/guide/multipart.asciidoc @@ -146,7 +146,7 @@ all bodies: [source,erlang] ---- multipart(Req0) -> - case cowboy_req:part(Req0) of + case cowboy_req:read_part(Req0) of {ok, _Headers, Req} -> multipart(Req); {done, Req} -> diff --git a/docs/en/cowboy/2.0/guide/multipart/index.html b/docs/en/cowboy/2.0/guide/multipart/index.html index e16dc5a9..dc3ea289 100644 --- a/docs/en/cowboy/2.0/guide/multipart/index.html +++ b/docs/en/cowboy/2.0/guide/multipart/index.html @@ -215,7 +215,7 @@ by Lorenzo Bettini http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #000000">multipart</span></span>(<span style="color: #009900">Req0</span>) <span style="color: #990000">-></span>
- <span style="font-weight: bold"><span style="color: #0000FF">case</span></span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:part</span></span>(<span style="color: #009900">Req0</span>) <span style="font-weight: bold"><span style="color: #0000FF">of</span></span>
+ <span style="font-weight: bold"><span style="color: #0000FF">case</span></span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:read_part</span></span>(<span style="color: #009900">Req0</span>) <span style="font-weight: bold"><span style="color: #0000FF">of</span></span>
{<span style="color: #FF6600">ok</span>, <span style="color: #009900">_Headers</span>, <span style="color: #009900">Req</span>} <span style="color: #990000">-></span>
<span style="font-weight: bold"><span style="color: #000000">multipart</span></span>(<span style="color: #009900">Req</span>);
{<span style="color: #FF6600">done</span>, <span style="color: #009900">Req</span>} <span style="color: #990000">-></span>
diff --git a/docs/en/cowboy/2.0/guide/overview/index.html b/docs/en/cowboy/2.0/guide/overview/index.html index 365bd2e8..6a62cea8 100644 --- a/docs/en/cowboy/2.0/guide/overview/index.html +++ b/docs/en/cowboy/2.0/guide/overview/index.html @@ -215,6 +215,21 @@ at this point, however.</p></div> + + + + + <nav style="margin:1em 0"> + + <a style="float:left" href="https://ninenines.eu/docs/en/cowboy/2.0/guide/hooks/"> + Hooks + </a> + + + + </nav> + + </div> diff --git a/docs/en/cowboy/2.0/guide/rest_handlers.asciidoc b/docs/en/cowboy/2.0/guide/rest_handlers.asciidoc index 748fca49..c69f02b2 100644 --- a/docs/en/cowboy/2.0/guide/rest_handlers.asciidoc +++ b/docs/en/cowboy/2.0/guide/rest_handlers.asciidoc @@ -101,13 +101,13 @@ and in the second case that we send one as HTML. === Meta data -Cowboy will set informative meta values at various points of the -execution. You can retrieve them using `cowboy_req:meta/{2,3}`. -The values are defined in the following table. +Cowboy will set informative values to the Req object at various +points of the execution. You can retrieve them by matching the +Req object directly. The values are defined in the following table: [cols="<,<",options="header"] |=== -| Meta key | Details +| Key | Details | media_type | The content-type negotiated for the response entity. | language | The language negotiated for the response entity. | charset | The charset negotiated for the response entity. diff --git a/docs/en/cowboy/2.0/guide/rest_handlers/index.html b/docs/en/cowboy/2.0/guide/rest_handlers/index.html index a0691398..5e7f84aa 100644 --- a/docs/en/cowboy/2.0/guide/rest_handlers/index.html +++ b/docs/en/cowboy/2.0/guide/rest_handlers/index.html @@ -258,9 +258,9 @@ and in the second case that we send one as HTML.</p></div> <div class="sect1">
<h2 id="_meta_data">Meta data</h2>
<div class="sectionbody">
-<div class="paragraph"><p>Cowboy will set informative meta values at various points of the
-execution. You can retrieve them using <code>cowboy_req:meta/{2,3}</code>.
-The values are defined in the following table.</p></div>
+<div class="paragraph"><p>Cowboy will set informative values to the Req object at various
+points of the execution. You can retrieve them by matching the
+Req object directly. The values are defined in the following table:</p></div>
<div class="tableblock">
<table rules="all"
width="100%"
@@ -270,7 +270,7 @@ cellspacing="0" cellpadding="4"> <col width="50%" />
<thead>
<tr>
-<th align="left" valign="top"> Meta key </th>
+<th align="left" valign="top"> Key </th>
<th align="left" valign="top"> Details</th>
</tr>
</thead>
diff --git a/docs/en/cowboy/2.0/guide/streams.asciidoc b/docs/en/cowboy/2.0/guide/streams.asciidoc new file mode 100644 index 00000000..243e5815 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/streams.asciidoc @@ -0,0 +1,15 @@ +[[streams]] +== Streams + +Placeholder chapter. + +Streams are a new feature in Cowboy 2.0 that requires +a little more tweaking before they can be generally +useful. This chapter will be made available in a future +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] diff --git a/docs/en/cowboy/2.0/guide/streams/index.html b/docs/en/cowboy/2.0/guide/streams/index.html new file mode 100644 index 00000000..ddaad48e --- /dev/null +++ b/docs/en/cowboy/2.0/guide/streams/index.html @@ -0,0 +1,182 @@ +<!DOCTYPE html> +<html lang="en"> + +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <meta name="description" content=""> + <meta name="author" content="Loïc Hoguin based on a design from (Soft10) Pol Cámara"> + + <meta name="generator" content="Hugo 0.17" /> + + <title>Nine Nines: Streams</title> + + <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" rel="stylesheet"> + + <link rel="shortcut icon" href="/img/ico/favicon.ico"> + <link rel="apple-touch-icon-precomposed" sizes="114x114" href="/img/ico/apple-touch-icon-114.png"> + <link rel="apple-touch-icon-precomposed" sizes="72x72" href="/img/ico/apple-touch-icon-72.png"> + <link rel="apple-touch-icon-precomposed" href="/img/ico/apple-touch-icon-57.png"> + + +</head> + + +<body class=""> + <header id="page-head"> + <div id="topbar" class="container"> + <div class="row"> + <div class="span2"> + <h1 id="logo"><a href="/" title="99s">99s</a></h1> + </div> + <div class="span10"> + + <div id="side-header"> + <nav> + <ul> + <li><a title="Hear my thoughts" href="/articles">Articles</a></li> + <li><a title="Watch my talks" href="/talks">Talks</a></li> + <li class="active"><a title="Read the docs" href="/docs">Documentation</a></li> + <li><a title="Request my services" href="/services">Consulting & Training</a></li> + </ul> + </nav> + <ul id="social"> + <li> + <a href="https://github.com/ninenines" title="Check my Github repositories"><img src="/img/ico_github.png" data-hover="/img/ico_github_alt.png" alt="Github"></a> + </li> + <li> + <a title="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></a> + </li> + <li> + <a title="Contact me" href="mailto:[email protected]"><img src="/img/ico_mail.png" data-hover="/img/ico_mail_alt.png"></a> + </li> + </ul> + </div> + </div> + </div> + </div> + + +</header> + +<div id="contents" class="two_col"> +<div class="container"> +<div class="row"> +<div id="docs" class="span9 maincol"> + +<h1 class="lined-header"><span>Streams</span></h1> + +<div class="paragraph"><p>Placeholder chapter.</p></div>
+<div class="paragraph"><p>Streams are a new feature in Cowboy 2.0 that requires
+a little more tweaking before they can be generally
+useful. This chapter will be made available in a future
+pre-release.</p></div>
+<div class="paragraph"><p>Streams are meant to replace hooks. The relevant chapters
+for Cowboy 1.0 were:</p></div>
+<div class="ulist"><ul>
+<li>
+<p>
+<a href="../hooks">Hooks</a>
+</p>
+</li>
+<li>
+<p>
+<a href="../broken_clients">Dealing with broken clients</a>
+</p>
+</li>
+</ul></div>
+ + + + + + + + <nav style="margin:1em 0"> + + <a style="float:left" href="https://ninenines.eu/docs/en/cowboy/2.0/guide/ws_handlers/"> + Websocket handlers + </a> + + + + <a style="float:right" href="https://ninenines.eu/docs/en/cowboy/2.0/guide/middlewares/"> + Middlewares + </a> + + </nav> + + + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</div> +</div> +</div> +</div> + + <footer> + <div class="container"> + <div class="row"> + <div class="span6"> + <p id="scroll-top"><a href="#">↑ Scroll to top</a></p> + <nav> + <ul> + <li><a href="mailto:[email protected]" title="Contact us">Contact us</a></li><li><a href="https://github.com/ninenines/ninenines.github.io" title="Github repository">Contribute to this site</a></li> + </ul> + </nav> + </div> + <div class="span6 credits"> + <p><img src="/img/footer_logo.png"></p> + <p>Copyright © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + diff --git a/docs/en/cowboy/2.0/guide/sub_protocols/index.html b/docs/en/cowboy/2.0/guide/sub_protocols/index.html index 6293bc08..29d8f3ea 100644 --- a/docs/en/cowboy/2.0/guide/sub_protocols/index.html +++ b/docs/en/cowboy/2.0/guide/sub_protocols/index.html @@ -148,8 +148,8 @@ the optional <code>terminate/3</code> callback is called, if present.</p></div> - <a style="float:right" href="https://ninenines.eu/docs/en/cowboy/2.0/guide/hooks/"> - Hooks + <a style="float:right" href="https://ninenines.eu/docs/en/cowboy/2.0/guide/architecture/"> + Architecture </a> </nav> diff --git a/docs/en/cowboy/2.0/guide/ws_handlers/index.html b/docs/en/cowboy/2.0/guide/ws_handlers/index.html index 5e484272..c3141194 100644 --- a/docs/en/cowboy/2.0/guide/ws_handlers/index.html +++ b/docs/en/cowboy/2.0/guide/ws_handlers/index.html @@ -347,8 +347,8 @@ close frame will not be sent.</p></div> - <a style="float:right" href="https://ninenines.eu/docs/en/cowboy/2.0/guide/architecture/"> - Architecture + <a style="float:right" href="https://ninenines.eu/docs/en/cowboy/2.0/guide/streams/"> + Streams </a> </nav> diff --git a/docs/index.xml b/docs/index.xml index 09ef6b82..edeafd2e 100644 --- a/docs/index.xml +++ b/docs/index.xml @@ -210,8 +210,6 @@ environment configuration parameters.</p></div> <a href="getting_started/">Getting started</a>
</p>
</li>
-</ul></div>
-<div class="ulist"><ul>
<li>
<p>
<a href="flow_diagram/">Flow diagram</a>
@@ -231,11 +229,6 @@ environment configuration parameters.</p></div> </li>
<li>
<p>
-<a href="streams/">Streams</a>
-</p>
-</li>
-<li>
-<p>
<a href="routing/">Routing</a>
</p>
</li>
@@ -339,45 +332,68 @@ environment configuration parameters.</p></div> </li>
<li>
<p>
-<a href="ws_handlers/">Handling Websocket connections</a>
+<a href="ws_handlers/">Websocket handlers</a>
</p>
</li>
</ul></div>
</div>
</div>
<div class="sect1">
-<h2 id="_internals">Internals</h2>
+<h2 id="_advanced">Advanced</h2>
<div class="sectionbody">
<div class="ulist"><ul>
<li>
<p>
-<a href="architecture/">Architecture</a>
+<a href="streams/">Streams</a>
+</p>
+</li>
+<li>
+<p>
+<a href="middlewares/">Middlewares</a>
</p>
</li>
</ul></div>
<div class="ulist"><ul>
<li>
<p>
-<a href="broken_clients/">Dealing with broken clients</a>
+<a href="sub_protocols/">Sub protocols</a>
</p>
</li>
+</ul></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_deprecated_chapters">Deprecated chapters</h2>
+<div class="sectionbody">
+</div>
+</div>
+<div class="sect1">
+<h2 id="_about_the_deprecated_chapters">About the deprecated chapters</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The following chapters were relevant in Cowboy 1.0. They have
+not been updated for Cowboy 2.0 yet. The information in these
+chapters may or may not be useful.</p></div>
+<div class="ulist"><ul>
<li>
<p>
-<a href="middlewares/">Middlewares</a>
+<a href="architecture/">Architecture</a>
</p>
</li>
<li>
<p>
-<a href="sub_protocols/">Sub protocols</a>
+<a href="broken_clients/">Dealing with broken clients</a>
</p>
</li>
-</ul></div>
-<div class="ulist"><ul>
<li>
<p>
<a href="hooks/">Hooks</a>
</p>
</li>
+<li>
+<p>
+<a href="overview/">Overview</a>
+</p>
+</li>
</ul></div>
</div>
</div>
@@ -1081,158 +1097,6 @@ client and the connection is closed.</p></div> </item> <item> - <title>Request overview</title> - <link>https://ninenines.eu/docs/en/cowboy/2.0/guide/overview/</link> - <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate> - - <guid>https://ninenines.eu/docs/en/cowboy/2.0/guide/overview/</guid> - <description><div class="paragraph"><p>This chapter explains the different steps a request
-goes through until a response is sent, along with
-details of the Cowboy implementation.</p></div>
-<div class="sect1">
-<h2 id="_request_response">Request/response</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>As you already know, HTTP clients connect to the server and
-send a request for a resource; the server then sends a
-response containing the resource if it could obtain it.</p></div>
-<div class="paragraph"><p>Before the server can send the resource, however, it
-needs to perform many different operations to read the
-request, find the resource, prepare the response being
-sent and often other related operations the user can
-add like writing logs.</p></div>
-<div class="paragraph"><p>Requests take the following route in Cowboy:</p></div>
-<div class="imageblock">
-<div class="content">
-<img src="../http_req_resp.png" alt="HTTP request/response flowchart" />
-</div>
-</div>
-<div class="paragraph"><p>This shows the default middlewares, but they may be
-configured differently in your setup. The dark green
-indicates the points where you can hook your own code,
-the light green is the Cowboy code that you can of
-course configure as needed.</p></div>
-<div class="paragraph"><p>The <code>acceptor</code> is the part of the server that accepts
-the connection and create an Erlang process to handle
-it. The <code>parser</code> then starts reading from the socket
-and handling requests as they come until the socket
-is closed.</p></div>
-<div class="paragraph"><p>A response may be sent at many different points in the
-life of the request. If Cowboy can&#8217;t parse the request,
-it gives up with an error response. If the router can&#8217;t
-find the resource, it sends a not found error. Your
-own code can of course send a response at any time.</p></div>
-<div class="paragraph"><p>When a response is sent, you can optionally modify it
-or act upon it by enabling the <code>onresponse</code> hook. By
-default the response is sent directly to the client.</p></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_and_then">And then?</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>Behavior depends on what protocol is in use.</p></div>
-<div class="paragraph"><p>HTTP/1.0 can only process one request per connection,
-so Cowboy will close the connection immediately after
-it sends the response.</p></div>
-<div class="paragraph"><p>HTTP/1.1 allows the client to request that the server
-keeps the connection alive. This mechanism is described
-in the next section.</p></div>
-<div class="paragraph"><p>HTTP/2 is designed to allow sending multiple requests
-asynchronously on the same connection. Details on what
-this means for your application is described in this
-chapter.</p></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_keep_alive_http_1_1">Keep-alive (HTTP/1.1)</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>With HTTP/1.1, the connection may be left open for
-subsequent requests to come. This mechanism is called
-<code>keep-alive</code>.</p></div>
-<div class="paragraph"><p>When the client sends a request to the server, it includes
-a header indicating whether it would like to leave the
-socket open. The server may or may not accept, indicating
-its choice by sending the same header in the response.</p></div>
-<div class="paragraph"><p>Cowboy will include this header automatically in all
-responses to HTTP/1.1 requests. You can however force
-the closing of the socket if you want. When Cowboy sees
-you want to send a <code>connection: close</code> header, it will
-not override it and will close the connection as soon
-as the reply is sent.</p></div>
-<div class="paragraph"><p>This snippet will force Cowboy to close the connection.</p></div>
-<div class="listingblock">
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:reply</span></span>(<span style="color: #993399">200</span>, [
- {<span style="color: #990000">&lt;&lt;</span><span style="color: #FF0000">"connection"</span><span style="color: #990000">&gt;&gt;</span>, <span style="color: #990000">&lt;&lt;</span><span style="color: #FF0000">"close"</span><span style="color: #990000">&gt;&gt;</span>},
-], <span style="color: #990000">&lt;&lt;</span><span style="color: #FF0000">"Closing the socket in 3.. 2.. 1.."</span><span style="color: #990000">&gt;&gt;</span>, <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
-<div class="paragraph"><p>Cowboy will only accept a certain number of new requests
-on the same connection. By default it will run up to 100
-requests. This number can be changed by setting the
-<code>max_keepalive</code> configuration value when starting an
-HTTP listener.</p></div>
-<div class="listingblock">
-<div class="content"><!-- Generator: GNU source-highlight 3.1.8
-by Lorenzo Bettini
-http://www.lorenzobettini.it
-http://www.gnu.org/software/src-highlite -->
-<pre><tt><span style="font-weight: bold"><span style="color: #000000">cowboy:start_http</span></span>(<span style="color: #FF6600">my_http_listener</span>, <span style="color: #993399">100</span>, [{<span style="color: #FF6600">port</span>, <span style="color: #993399">8080</span>}], [
- {<span style="color: #FF6600">env</span>, [{<span style="color: #FF6600">dispatch</span>, <span style="color: #009900">Dispatch</span>}]},
- {<span style="color: #FF6600">max_keepalive</span>, <span style="color: #993399">5</span>}
-])<span style="color: #990000">.</span></tt></pre></div></div>
-<div class="paragraph"><p>Cowboy implements the keep-alive mechanism by reusing
-the same process for all requests. This allows Cowboy
-to save memory. This works well because most code will
-not have any side effect impacting subsequent requests.
-But it also means you need to clean up if you do have
-code with side effects. The <code>terminate/3</code> function can
-be used for this purpose.</p></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_pipelining_http_1_1">Pipelining (HTTP/1.1)</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>While HTTP is designed as a sequential protocol, with
-the client sending a request and then waiting for the
-response from the server, nothing prevents the client
-from sending more requests to the server without waiting
-for the response, due to how sockets work. The server
-still handles the requests sequentially and sends the
-responses in the same order.</p></div>
-<div class="paragraph"><p>This mechanism is called pipelining. It allows reducing
-latency when a client needs to request many resources
-at the same time. This is used by browsers when requesting
-static files for example.</p></div>
-<div class="paragraph"><p>This is handled automatically by the server.</p></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_asynchronous_requests_http_2">Asynchronous requests (HTTP/2)</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>In HTTP/2, the client can send a request at any time.
-And the server can send a response at any time too.</p></div>
-<div class="paragraph"><p>This means for example that the client does not need
-to wait for a request to be fully sent to send another,
-it is possible to interleave a request with the request
-body of another request. The same is true with responses.
-Responses may also be sent in a different order.</p></div>
-<div class="paragraph"><p>Because requests and responses are fully asynchronous,
-Cowboy creates a new process for each request, and these
-processes are managed by another process that handles the
-connection itself.</p></div>
-<div class="paragraph"><p>HTTP/2 servers may also decide to send resources to the
-client before the client requests them. This is especially
-useful for sending static files associated with the HTML
-page requested, as this reduces the latency of the overall
-response. Cowboy does not support this particular mechanism
-at this point, however.</p></div>
-</div>
-</div>
-</description> - </item> - - <item> <title>cowboy(3)</title> <link>https://ninenines.eu/docs/en/cowboy/2.0/manual/cowboy/</link> <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate> @@ -1825,5 +1689,183 @@ http://www.gnu.org/software/src-highlite --> </description> </item> + <item> + <title>cowboy:start_tls(3)</title> + <link>https://ninenines.eu/docs/en/cowboy/2.0/manual/cowboy.start_tls/</link> + <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate> + + <guid>https://ninenines.eu/docs/en/cowboy/2.0/manual/cowboy.start_tls/</guid> + <description><div class="sect1">
+<h2 id="_name">Name</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>cowboy:start_tls - Listen for connections using TLS</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_description">Description</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #000000">start_tls</span></span>(<span style="color: #009900">Name</span> <span style="color: #990000">::</span> <span style="font-weight: bold"><span style="color: #000000">ranch:ref</span></span>(),
+ <span style="color: #009900">NumAcceptors</span> <span style="color: #990000">::</span> <span style="font-weight: bold"><span style="color: #000000">non_neg_integer</span></span>(),
+ <span style="color: #009900">TransportOpts</span> <span style="color: #990000">::</span> <span style="font-weight: bold"><span style="color: #000000">ranch_ssl:opts</span></span>(),
+ <span style="color: #009900">ProtocolOpts</span> <span style="color: #990000">::</span> <span style="font-weight: bold"><span style="color: #000000">opts</span></span>())
+ <span style="color: #990000">-&gt;</span> {<span style="color: #FF6600">ok</span>, <span style="color: #009900">ListenerPid</span> <span style="color: #990000">::</span> <span style="font-weight: bold"><span style="color: #000080">pid</span></span>()}
+ | {<span style="color: #FF6600">error</span>, <span style="font-weight: bold"><span style="color: #000000">any</span></span>()}</tt></pre></div></div>
+<div class="paragraph"><p>Start listening for connections over a secure TLS channel.</p></div>
+<div class="paragraph"><p>Both HTTP/1.1 and HTTP/2 are supported on this listener.
+The ALPN TLS extension must be used to initiate an HTTP/2
+connection.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_arguments">Arguments</h2>
+<div class="sectionbody">
+<div class="dlist"><dl>
+<dt class="hdlist1">
+Name
+</dt>
+<dd>
+<p>
+The listener name is used to refer to this listener in
+future calls, for example when stopping it or when
+updating the routes defined.
+</p>
+<div class="paragraph"><p>It can be any Erlang term. An atom is generally good enough,
+for example <code>api</code>, <code>my_app_clear</code> or <code>my_app_tls</code>.</p></div>
+</dd>
+<dt class="hdlist1">
+NumAcceptors
+</dt>
+<dd>
+<p>
+The number of acceptors is the number of processes that
+will accept connections. Tweak this value to improve the
+accept rate for incoming connections.
+</p>
+<div class="paragraph"><p>The ideal value is between 10 and 100 on most systems.
+Larger values may have the opposite effect and reduce the
+accept rate. It&#8217;s generally safe to start with a value of
+100 (or 10 on low memory systems). Then, when accept rates
+become a concern, measure the performance and update the
+value accordingly.</p></div>
+<div class="paragraph"><p>This value is unrelated to the maximum number of concurrent
+connections.</p></div>
+</dd>
+<dt class="hdlist1">
+TransportOpts
+</dt>
+<dd>
+<p>
+The transport options are where the TCP options, including
+the listener&#8217;s port number, are defined. They also contain
+the TLS options, like the server&#8217;s certificate. Transport options
+are provided as a list of keys and values, for example
+<code>[{port, 8443}, {certfile, "path/to/cert.pem"}]</code>.
+</p>
+<div class="paragraph"><p>The available options are documented in the
+<a href="../ranch_ssl">ranch_ssl(3)</a> manual.</p></div>
+</dd>
+<dt class="hdlist1">
+ProtocolOpts
+</dt>
+<dd>
+<p>
+The protocol options are in a map containing all the options for
+the different protocols that may be involved when connecting
+to the listener, including HTTP/1.1 and HTTP/2 but also
+subprotocols like Websocket.
+</p>
+<div class="paragraph"><p>The HTTP/1.1 options are documented in the
+<a href="../cowboy_http">cowboy_http(3)</a> manual;
+the HTTP/2 options in
+<a href="../cowboy_http2">cowboy_http2(3)</a>;
+and the Websocket options in
+<a href="../cowboy_websocket">cowboy_websocket(3)</a>.</p></div>
+</dd>
+</dl></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_return_value">Return value</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>An ok tuple is returned on success. It contains the pid of
+the top-level supervisor for the listener.</p></div>
+<div class="paragraph"><p>An error tuple is returned on error. The error reason may
+be any Erlang term.</p></div>
+<div class="paragraph"><p>A common error is <code>eaddrinuse</code>. It indicates that the port
+configured for Cowboy is already in use.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_changelog">Changelog</h2>
+<div class="sectionbody">
+<div class="ulist"><ul>
+<li>
+<p>
+<strong>2.0</strong>: HTTP/2 support added.
+</p>
+</li>
+<li>
+<p>
+<strong>2.0</strong>: Function introduced. Replaces <code>cowboy:start_https/4</code>.
+</p>
+</li>
+</ul></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_examples">Examples</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="title">Start a listener</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="color: #009900">Dispatch</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_router:compile</span></span>([
+ {<span style="color: #FF6600">'_'</span>, [
+ {<span style="color: #FF0000">"/"</span>, <span style="color: #FF6600">toppage_h</span>, []}
+ ]}
+]),
+
+{<span style="color: #FF6600">ok</span>, <span style="color: #990000">_</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy:start_tls</span></span>(<span style="color: #FF6600">example</span>, <span style="color: #993399">100</span>, [
+ {<span style="color: #FF6600">port</span>, <span style="color: #993399">8443</span>},
+ {<span style="color: #FF6600">cert</span>, <span style="color: #FF0000">"path/to/cert.pem"</span>}
+], #{
+ <span style="color: #0000FF">env</span> <span style="color: #990000">=&gt;</span> #{<span style="color: #0000FF">dispatch</span> <span style="color: #990000">=&gt;</span> <span style="color: #009900">Dispatch</span>}
+})<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="listingblock">
+<div class="title">Start a listener on a random port</div>
+<div class="content"><!-- Generator: GNU source-highlight 3.1.8
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="color: #009900">Name</span> <span style="color: #990000">=</span> <span style="color: #FF6600">example</span>,
+
+{<span style="color: #FF6600">ok</span>, <span style="color: #990000">_</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy:start_tls</span></span>(<span style="color: #009900">Name</span>, <span style="color: #993399">100</span>, [
+ {<span style="color: #FF6600">cert</span>, <span style="color: #FF0000">"path/to/cert.pem"</span>}
+], #{
+ <span style="color: #0000FF">env</span> <span style="color: #990000">=&gt;</span> #{<span style="color: #0000FF">dispatch</span> <span style="color: #990000">=&gt;</span> <span style="color: #009900">Dispatch</span>}
+}),
+
+<span style="color: #009900">Port</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">ranch:get_port</span></span>(<span style="color: #009900">Name</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_see_also">See also</h2>
+<div class="sectionbody">
+<div class="paragraph"><p><a href="../cowboy">cowboy(3)</a>,
+<a href="../cowboy.start_clear">cowboy:start_clear(3)</a>,
+<a href="../cowboy.stop_listener">cowboy:stop_listener(3)</a>,
+<a href="../ranch">ranch(3)</a></p></div>
+</div>
+</div>
+</description> + </item> + </channel> </rss>
\ No newline at end of file |