aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2013-09-07 21:58:03 +0200
committerLoïc Hoguin <[email protected]>2013-09-07 21:58:03 +0200
commit340f0a51123b476bca765b87d3f36411e896b5e3 (patch)
treeabeb1a43aa027f3b209c7b42a573b090b1a1deb1 /examples
parent2f25c654b02d72a7c0017c20d11ed6a720d640c6 (diff)
downloadcowboy-340f0a51123b476bca765b87d3f36411e896b5e3.tar.gz
cowboy-340f0a51123b476bca765b87d3f36411e896b5e3.tar.bz2
cowboy-340f0a51123b476bca765b87d3f36411e896b5e3.zip
Convert the cookie example to a release
Diffstat (limited to 'examples')
-rw-r--r--examples/cookie/Makefile15
-rw-r--r--examples/cookie/README.md27
-rw-r--r--examples/cookie/rebar.config6
-rw-r--r--examples/cookie/relx.config2
-rw-r--r--examples/cookie/src/cookie.app.src3
-rw-r--r--examples/cookie/src/cookie.erl15
-rwxr-xr-xexamples/cookie/start.sh3
7 files changed, 34 insertions, 37 deletions
diff --git a/examples/cookie/Makefile b/examples/cookie/Makefile
new file mode 100644
index 0000000..fe61f29
--- /dev/null
+++ b/examples/cookie/Makefile
@@ -0,0 +1,15 @@
+PROJECT = cookie
+
+DEPS = cowboy erlydtl
+dep_cowboy = pkg://cowboy master
+dep_erlydtl = pkg://erlydtl master
+
+.PHONY: release clean-release
+
+release: clean-release all
+ relx
+
+clean-release:
+ rm -rf _rel
+
+include ../../erlang.mk
diff --git a/examples/cookie/README.md b/examples/cookie/README.md
index cb6465f..8e1632a 100644
--- a/examples/cookie/README.md
+++ b/examples/cookie/README.md
@@ -1,18 +1,21 @@
-Cowboy Cookie
-=============
+Cookie example
+==============
-To compile this example you need rebar in your PATH.
+To try this example, you need GNU `make`, `git` and
+[relx](https://github.com/erlware/relx) in your PATH.
-Type the following command:
-```
-$ rebar get-deps compile
-```
+To build the example, run the following command:
-You can then start the Erlang node with the following command:
+``` bash
+$ make
```
-./start.sh
+
+To start the release in the foreground:
+
+``` bash
+$ ./_rel/bin/cookie_example console
```
-Then point your browser to the indicated URL. This example allows
-you to use any path you want to try to show that cookies are defined
-site-wide. Try it in your browser!
+Then point your browser at [http://localhost:8080](http://localhost:8080).
+This example allows you to use any path to show that the cookies
+are defined site-wide. Try it!
diff --git a/examples/cookie/rebar.config b/examples/cookie/rebar.config
deleted file mode 100644
index d1fecef..0000000
--- a/examples/cookie/rebar.config
+++ /dev/null
@@ -1,6 +0,0 @@
-{deps, [
- {cowboy, ".*",
- {git, "git://github.com/extend/cowboy.git", "master"}},
- {erlydtl, ".*",
- {git, "https://github.com/evanmiller/erlydtl.git", "master"}}
-]}.
diff --git a/examples/cookie/relx.config b/examples/cookie/relx.config
new file mode 100644
index 0000000..26dc875
--- /dev/null
+++ b/examples/cookie/relx.config
@@ -0,0 +1,2 @@
+{release, {cookie_example, "1"}, [cookie]}.
+{extended_start_script, true}.
diff --git a/examples/cookie/src/cookie.app.src b/examples/cookie/src/cookie.app.src
index 1e9cd3d..b7098f0 100644
--- a/examples/cookie/src/cookie.app.src
+++ b/examples/cookie/src/cookie.app.src
@@ -8,7 +8,8 @@
{applications, [
kernel,
stdlib,
- cowboy
+ cowboy,
+ erlydtl
]},
{mod, {cookie_app, []}},
{env, []}
diff --git a/examples/cookie/src/cookie.erl b/examples/cookie/src/cookie.erl
deleted file mode 100644
index 2626b39..0000000
--- a/examples/cookie/src/cookie.erl
+++ /dev/null
@@ -1,15 +0,0 @@
-%% Feel free to use, reuse and abuse the code in this file.
-
--module(cookie).
-
-%% API.
--export([start/0]).
-
-%% API.
-
-start() ->
- ok = application:start(crypto),
- ok = application:start(cowlib),
- ok = application:start(ranch),
- ok = application:start(cowboy),
- ok = application:start(cookie).
diff --git a/examples/cookie/start.sh b/examples/cookie/start.sh
deleted file mode 100755
index 7b1d728..0000000
--- a/examples/cookie/start.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-erl -pa ebin deps/*/ebin -s cookie \
- -eval "io:format(\"Point your browser at http://localhost:8080~n\")."