aboutsummaryrefslogtreecommitdiffstats
path: root/examples/echo_post
diff options
context:
space:
mode:
Diffstat (limited to 'examples/echo_post')
-rw-r--r--examples/echo_post/Makefile14
-rw-r--r--examples/echo_post/README.md38
-rwxr-xr-xexamples/echo_post/curl_post.sh2
-rw-r--r--examples/echo_post/rebar.config4
-rw-r--r--examples/echo_post/relx.config2
-rw-r--r--examples/echo_post/src/echo_post.erl15
-rwxr-xr-xexamples/echo_post/start.sh3
7 files changed, 34 insertions, 44 deletions
diff --git a/examples/echo_post/Makefile b/examples/echo_post/Makefile
new file mode 100644
index 0000000..10ce980
--- /dev/null
+++ b/examples/echo_post/Makefile
@@ -0,0 +1,14 @@
+PROJECT = echo_post
+
+DEPS = cowboy
+dep_cowboy = pkg://cowboy master
+
+.PHONY: release clean-release
+
+release: clean-release all
+ relx
+
+clean-release:
+ rm -rf _rel
+
+include ../../erlang.mk
diff --git a/examples/echo_post/README.md b/examples/echo_post/README.md
index 66b7ee5..2615352 100644
--- a/examples/echo_post/README.md
+++ b/examples/echo_post/README.md
@@ -1,30 +1,28 @@
-Cowboy POST Echo
-================
+POST parameter echo 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:
-```
-./start.sh
+``` bash
+$ make
```
-Then point your browser to the indicated URL. You can change
-the GET parameter to check that the handler is echoing properly.
+To start the release in the foreground:
-Then run the following command, replacing STRING_TO_ECHO by the
-string you want to echo. Check the ```curl_post.sh``` file for details.
-
-```
-./curl_post.sh STRING_TO_ECHO
+``` bash
+$ ./_rel/bin/echo_post_example console
```
-Example
--------
+As this example echoes a POST parameter, it is a little more
+complex to test. Some browsers feature tools that allow you
+to perform one such request, or you can use the command line
+tool `curl` as we will demonstrate.
+
+Example output
+--------------
``` bash
$ curl -i -d echo=echomeplz http://localhost:8080
@@ -33,7 +31,7 @@ connection: keep-alive
server: Cowboy
date: Fri, 28 Sep 2012 04:12:36 GMT
content-length: 9
-Content-Encoding: utf-8
+content-type: text/plain; charset=utf-8
echomeplz
```
diff --git a/examples/echo_post/curl_post.sh b/examples/echo_post/curl_post.sh
deleted file mode 100755
index c9ec987..0000000
--- a/examples/echo_post/curl_post.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-curl -i -d echo=$1 http://localhost:8080
diff --git a/examples/echo_post/rebar.config b/examples/echo_post/rebar.config
deleted file mode 100644
index 6ad3062..0000000
--- a/examples/echo_post/rebar.config
+++ /dev/null
@@ -1,4 +0,0 @@
-{deps, [
- {cowboy, ".*",
- {git, "git://github.com/extend/cowboy.git", "master"}}
-]}.
diff --git a/examples/echo_post/relx.config b/examples/echo_post/relx.config
new file mode 100644
index 0000000..a1abbf0
--- /dev/null
+++ b/examples/echo_post/relx.config
@@ -0,0 +1,2 @@
+{release, {echo_post_example, "1"}, [echo_post]}.
+{extended_start_script, true}.
diff --git a/examples/echo_post/src/echo_post.erl b/examples/echo_post/src/echo_post.erl
deleted file mode 100644
index 1f2a2ea..0000000
--- a/examples/echo_post/src/echo_post.erl
+++ /dev/null
@@ -1,15 +0,0 @@
-%% Feel free to use, reuse and abuse the code in this file.
-
--module(echo_post).
-
-%% 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(echo_post).
diff --git a/examples/echo_post/start.sh b/examples/echo_post/start.sh
deleted file mode 100755
index 8444136..0000000
--- a/examples/echo_post/start.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-erl -pa ebin deps/*/ebin -s echo_post \
- -eval "io:format(\"Run ./curl_post.sh STRING_TO_ECHO~n\")."