aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2013-09-07 20:45:21 +0200
committerLoïc Hoguin <[email protected]>2013-09-07 20:45:21 +0200
commit2f25c654b02d72a7c0017c20d11ed6a720d640c6 (patch)
tree95b47ff1a338abe955a18e2e245c91ab9b406707 /examples
parent4b20f5cd08bc69d95d81d47bff943f775c1a983e (diff)
downloadcowboy-2f25c654b02d72a7c0017c20d11ed6a720d640c6.tar.gz
cowboy-2f25c654b02d72a7c0017c20d11ed6a720d640c6.tar.bz2
cowboy-2f25c654b02d72a7c0017c20d11ed6a720d640c6.zip
Convert the compressed response example to a release
Diffstat (limited to 'examples')
-rw-r--r--examples/compress_response/Makefile14
-rw-r--r--examples/compress_response/README.md33
-rw-r--r--examples/compress_response/rebar.config4
-rw-r--r--examples/compress_response/relx.config2
-rw-r--r--examples/compress_response/src/compress_response.erl15
-rwxr-xr-xexamples/compress_response/start.sh3
6 files changed, 37 insertions, 34 deletions
diff --git a/examples/compress_response/Makefile b/examples/compress_response/Makefile
new file mode 100644
index 0000000..4841147
--- /dev/null
+++ b/examples/compress_response/Makefile
@@ -0,0 +1,14 @@
+PROJECT = compress_response
+
+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/compress_response/README.md b/examples/compress_response/README.md
index 8afbe65..aa352c9 100644
--- a/examples/compress_response/README.md
+++ b/examples/compress_response/README.md
@@ -1,22 +1,27 @@
-Cowboy Compress Response
-========================
+Compressed response 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/compress_response_example console
```
-Then point your browser to the indicated URL.
+Then point your browser at [http://localhost:8080](http://localhost:8080).
+
+Example output
+--------------
-Example
--------
+Without compression:
``` bash
$ curl -i http://localhost:8080
@@ -38,7 +43,11 @@ have established the ability to work at virtually identical tasks and obtained
considerable respect for their achievements. There are also cattle handlers
in many other parts of the world, particularly South America and Australia,
who perform work similar to the cowboy in their respective nations.
+```
+With compression:
+
+```
$ curl -i --compressed http://localhost:8080
HTTP/1.1 200 OK
connection: keep-alive
diff --git a/examples/compress_response/rebar.config b/examples/compress_response/rebar.config
deleted file mode 100644
index 6ad3062..0000000
--- a/examples/compress_response/rebar.config
+++ /dev/null
@@ -1,4 +0,0 @@
-{deps, [
- {cowboy, ".*",
- {git, "git://github.com/extend/cowboy.git", "master"}}
-]}.
diff --git a/examples/compress_response/relx.config b/examples/compress_response/relx.config
new file mode 100644
index 0000000..1544349
--- /dev/null
+++ b/examples/compress_response/relx.config
@@ -0,0 +1,2 @@
+{release, {compress_response_example, "1"}, [compress_response]}.
+{extended_start_script, true}.
diff --git a/examples/compress_response/src/compress_response.erl b/examples/compress_response/src/compress_response.erl
deleted file mode 100644
index c69a14b..0000000
--- a/examples/compress_response/src/compress_response.erl
+++ /dev/null
@@ -1,15 +0,0 @@
-%% Feel free to use, reuse and abuse the code in this file.
-
--module(compress_response).
-
-%% 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(compress_response).
diff --git a/examples/compress_response/start.sh b/examples/compress_response/start.sh
deleted file mode 100755
index 2e79031..0000000
--- a/examples/compress_response/start.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-erl -pa ebin deps/*/ebin -s compress_response \
- -eval "io:format(\"Point your browser at http://localhost:8080~n\")."