diff options
author | Loïc Hoguin <[email protected]> | 2013-09-08 11:48:48 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2013-09-08 11:48:48 +0200 |
commit | 49acfce8b9d0af8cc87b9be7ba91ffde307596da (patch) | |
tree | c7727f3f520b3d66401951004d9d4eac575f5380 /examples | |
parent | 6b7b0efd24149d81df47b3241a989a6777bb486b (diff) | |
download | cowboy-49acfce8b9d0af8cc87b9be7ba91ffde307596da.tar.gz cowboy-49acfce8b9d0af8cc87b9be7ba91ffde307596da.tar.bz2 cowboy-49acfce8b9d0af8cc87b9be7ba91ffde307596da.zip |
Convert the EventSource example to a release
Diffstat (limited to 'examples')
-rw-r--r-- | examples/eventsource/Makefile | 14 | ||||
-rw-r--r-- | examples/eventsource/README.md | 28 | ||||
-rw-r--r-- | examples/eventsource/rebar.config | 6 | ||||
-rw-r--r-- | examples/eventsource/relx.config | 2 | ||||
-rw-r--r-- | examples/eventsource/src/eventsource.erl | 15 | ||||
-rw-r--r-- | examples/eventsource/src/eventsource_app.erl | 2 | ||||
-rwxr-xr-x | examples/eventsource/start.sh | 3 |
7 files changed, 30 insertions, 40 deletions
diff --git a/examples/eventsource/Makefile b/examples/eventsource/Makefile new file mode 100644 index 0000000..176c9e0 --- /dev/null +++ b/examples/eventsource/Makefile @@ -0,0 +1,14 @@ +PROJECT = eventsource + +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/eventsource/README.md b/examples/eventsource/README.md index c9662a1..a748b06 100644 --- a/examples/eventsource/README.md +++ b/examples/eventsource/README.md @@ -1,22 +1,20 @@ -Cowboy EventSource -================== +EventSource 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 ``` -Uses Cowboy's loop functionality to continuously send events to the browser. +To start the release in the foreground: -Example -------- +``` bash +$ ./_rel/bin/eventsource_example console +``` -Point your browser to http://localhost:8080 to see EventSource in action with -any modern browser (not IE). +Then point your EventSource capable browser at +[http://localhost:8080](http://localhost:8080). diff --git a/examples/eventsource/rebar.config b/examples/eventsource/rebar.config deleted file mode 100644 index eb6f194..0000000 --- a/examples/eventsource/rebar.config +++ /dev/null @@ -1,6 +0,0 @@ -{deps, [ - {cowboy, ".*", - {git, "git://github.com/extend/cowboy.git", "master"}}, - {mimetypes, ".*", - {git, "git://github.com/spawngrid/mimetypes.git", "master"}} -]}. diff --git a/examples/eventsource/relx.config b/examples/eventsource/relx.config new file mode 100644 index 0000000..efd8548 --- /dev/null +++ b/examples/eventsource/relx.config @@ -0,0 +1,2 @@ +{release, {eventsource_example, "1"}, [eventsource]}. +{extended_start_script, true}. diff --git a/examples/eventsource/src/eventsource.erl b/examples/eventsource/src/eventsource.erl deleted file mode 100644 index bb85991..0000000 --- a/examples/eventsource/src/eventsource.erl +++ /dev/null @@ -1,15 +0,0 @@ -%% Feel free to use, reuse and abuse the code in this file. - --module(eventsource). - -%% 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(eventsource). diff --git a/examples/eventsource/src/eventsource_app.erl b/examples/eventsource/src/eventsource_app.erl index d002676..4f5594b 100644 --- a/examples/eventsource/src/eventsource_app.erl +++ b/examples/eventsource/src/eventsource_app.erl @@ -17,7 +17,7 @@ start(_Type, _Args) -> {"/", cowboy_static, [ {directory, {priv_dir, eventsource, []}}, {file, <<"index.html">>}, - {mimetypes, {fun mimetypes:path_to_mimes/2, default}} + {mimetypes, [{<<".html">>, [<<"text/html">>]}]} ]} ]} ]), diff --git a/examples/eventsource/start.sh b/examples/eventsource/start.sh deleted file mode 100755 index e97398f..0000000 --- a/examples/eventsource/start.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -erl -pa ebin deps/*/ebin -s eventsource \ - -eval "io:format(\"Point your browser at http://localhost:8080/~n\")." |