diff options
author | Loïc Hoguin <[email protected]> | 2019-10-16 09:48:31 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2019-10-16 09:48:31 +0200 |
commit | 8459bebceb9533948193774371cbd9fd571b78ea (patch) | |
tree | dd8e5eb8aa21e68b47f2526a3db9a276ea0d4327 /docs/en/cowboy/2.3/guide/getting_started | |
parent | 31cedd105e5f6ecfbfcb925d4703cdf7b5ae114f (diff) | |
download | ninenines.eu-8459bebceb9533948193774371cbd9fd571b78ea.tar.gz ninenines.eu-8459bebceb9533948193774371cbd9fd571b78ea.tar.bz2 ninenines.eu-8459bebceb9533948193774371cbd9fd571b78ea.zip |
Cowboy 2.7.0
Diffstat (limited to 'docs/en/cowboy/2.3/guide/getting_started')
-rw-r--r-- | docs/en/cowboy/2.3/guide/getting_started/index.html | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/docs/en/cowboy/2.3/guide/getting_started/index.html b/docs/en/cowboy/2.3/guide/getting_started/index.html index 4f392c17..894f60a3 100644 --- a/docs/en/cowboy/2.3/guide/getting_started/index.html +++ b/docs/en/cowboy/2.3/guide/getting_started/index.html @@ -68,7 +68,7 @@ <p>We are going to use the <a href="https://github.com/ninenines/erlang.mk">Erlang.mk</a> build system. If you are using Windows, please check the <a href="http://erlang.mk/guide/installation.html">Installation instructions</a> to get your environment setup before you continue.</p> <h2 id="_bootstrap">Bootstrap</h2> <p>First, let's create the directory for our application.</p> -<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.8 +<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9 by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> @@ -76,21 +76,21 @@ http://www.gnu.org/software/src-highlite --> $ cd hello_erlang</tt></pre> </div></div> <p>Then we need to download Erlang.mk. Either use the following command or download it manually.</p> -<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.8 +<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9 by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> <pre><tt>$ wget https<font color="#990000">:</font>//erlang<font color="#990000">.</font>mk/erlang<font color="#990000">.</font>mk</tt></pre> </div></div> <p>We can now bootstrap our application. Since we are going to generate a release, we will also bootstrap it at the same time.</p> -<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.8 +<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9 by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> <pre><tt>$ make -f erlang<font color="#990000">.</font>mk bootstrap bootstrap-rel</tt></pre> </div></div> <p>This creates a Makefile, a base application, and the release files necessary for creating the release. We can already build and start this release.</p> -<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.8 +<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9 by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> @@ -102,7 +102,7 @@ http://www.gnu.org/software/src-highlite --> <p>The release currently does nothing. In the rest of this chapter we will add Cowboy as a dependency and write a simple "Hello world!" handler.</p> <h2 id="_cowboy_setup">Cowboy setup</h2> <p>We will modify the <em>Makefile</em> to tell the build system it needs to fetch and compile Cowboy:</p> -<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.8 +<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9 by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> @@ -120,7 +120,7 @@ include erlang.mk</tt></pre> <h2 id="_listening_for_connections">Listening for connections</h2> <p>First we define the routes that Cowboy will use to map requests to handler modules, and then we start the listener. This is best done at application startup.</p> <p>Open the <em>src/hello_erlang_app.erl</em> file and add the necessary code to the <code>start/2</code> function to make it look like this:</p> -<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.8 +<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9 by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> @@ -139,14 +139,14 @@ http://www.gnu.org/software/src-highlite --> <h2 id="_handling_requests">Handling requests</h2> <p>Cowboy features different kinds of handlers, including REST and Websocket handlers. For this tutorial we will use a plain HTTP handler.</p> <p>Generate a handler from a template:</p> -<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.8 +<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9 by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> <pre><tt>$ make new <font color="#009900">t</font><font color="#990000">=</font>cowboy<font color="#990000">.</font>http <font color="#009900">n</font><font color="#990000">=</font>hello_handler</tt></pre> </div></div> <p>Then, open the <em>src/hello_handler.erl</em> file and modify the <code>init/2</code> function like this to send a reply.</p> -<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.8 +<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9 by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> @@ -216,6 +216,8 @@ http://www.gnu.org/software/src-highlite --> + <li><a href="/docs/en/cowboy/2.7/guide">2.7</a></li> + <li><a href="/docs/en/cowboy/2.6/guide">2.6</a></li> <li><a href="/docs/en/cowboy/2.5/guide">2.5</a></li> |