@@ -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
@@ -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
--------
+$ ./_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).
@@ -1,6 +0,0 @@
-{deps, [
- {cowboy, ".*",
- {git, "git://github.com/extend/cowboy.git", "master"}},
- {mimetypes, ".*",
- {git, "git://github.com/spawngrid/mimetypes.git", "master"}}
-]}.
@@ -0,0 +1,2 @@
+{release, {eventsource_example, "1"}, [eventsource]}.
+{extended_start_script, true}.
@@ -1,15 +0,0 @@
-%% Feel free to use, reuse and abuse the code in this file.
-
--module(eventsource).
-%% API.
--export([start/0]).
-start() ->
- ok = application:start(crypto),
- ok = application:start(cowlib),
- ok = application:start(ranch),
- ok = application:start(cowboy),
- ok = application:start(eventsource).
@@ -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">>]}]}
]}
]),
@@ -1,3 +0,0 @@
-#!/bin/sh
-erl -pa ebin deps/*/ebin -s eventsource \
- -eval "io:format(\"Point your browser at http://localhost:8080/~n\")."