mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 04:10:24 +00:00
Convert the EventSource example to a release
This commit is contained in:
parent
6b7b0efd24
commit
49acfce8b9
7 changed files with 31 additions and 41 deletions
14
examples/eventsource/Makefile
Normal file
14
examples/eventsource/Makefile
Normal file
|
@ -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:
|
||||
|
||||
``` bash
|
||||
$ make
|
||||
```
|
||||
|
||||
You can then start the Erlang node with the following command:
|
||||
```
|
||||
./start.sh
|
||||
To start the release in the foreground:
|
||||
|
||||
``` bash
|
||||
$ ./_rel/bin/eventsource_example console
|
||||
```
|
||||
|
||||
Uses Cowboy's loop functionality to continuously send events to the browser.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
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"}}
|
||||
]}.
|
2
examples/eventsource/relx.config
Normal file
2
examples/eventsource/relx.config
Normal file
|
@ -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]).
|
||||
|
||||
%% API.
|
||||
|
||||
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\")."
|
Loading…
Add table
Add a link
Reference in a new issue