summaryrefslogtreecommitdiffstats
path: root/examples/clock
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2013-02-14 17:24:38 +0100
committerLoïc Hoguin <[email protected]>2013-02-14 17:24:38 +0100
commitb813607d036251dcdb977500b6a75c1a110825c4 (patch)
tree96dcfe8deb9215f6585c9755bcfc180c848387e4 /examples/clock
parentd9f06ebc5625ac63203122e086b484a422da08fd (diff)
downloadbullet-b813607d036251dcdb977500b6a75c1a110825c4.tar.gz
bullet-b813607d036251dcdb977500b6a75c1a110825c4.tar.bz2
bullet-b813607d036251dcdb977500b6a75c1a110825c4.zip
Update to Cowboy 0.8.0
Diffstat (limited to 'examples/clock')
-rw-r--r--examples/clock/src/clock.erl2
-rw-r--r--examples/clock/src/clock_app.erl15
-rw-r--r--examples/clock/src/toppage_handler.erl6
3 files changed, 12 insertions, 11 deletions
diff --git a/examples/clock/src/clock.erl b/examples/clock/src/clock.erl
index a4a2988..e8547e1 100644
--- a/examples/clock/src/clock.erl
+++ b/examples/clock/src/clock.erl
@@ -20,5 +20,7 @@
%% API.
start() ->
+ ok = application:start(crypto),
+ ok = application:start(ranch),
ok = application:start(cowboy),
ok = application:start(clock).
diff --git a/examples/clock/src/clock_app.erl b/examples/clock/src/clock_app.erl
index 71de61f..9b3985f 100644
--- a/examples/clock/src/clock_app.erl
+++ b/examples/clock/src/clock_app.erl
@@ -11,21 +11,20 @@
%% API.
start(_Type, _Args) ->
- Dispatch = [
+ Dispatch = cowboy_router:compile([
{'_', [
- {[], toppage_handler, []},
- {[<<"bullet">>], bullet_handler, [{handler, stream_handler}]},
- {[<<"static">>, '...'], cowboy_http_static, [
+ {"/", toppage_handler, []},
+ {"/bullet", bullet_handler, [{handler, stream_handler}]},
+ {"/static/[...]", cowboy_static, [
{directory, {priv_dir, bullet, []}},
{mimetypes, [
{<<".js">>, [<<"application/javascript">>]}
]}
]}
]}
- ],
- {ok, _} = cowboy:start_listener(http, 100,
- cowboy_tcp_transport, [{port, 8080}],
- cowboy_http_protocol, [{dispatch, Dispatch}]
+ ]),
+ {ok, _} = cowboy:start_http(http, 100,
+ [{port, 8080}], [{env, [{dispatch, Dispatch}]}]
),
clock_sup:start_link().
diff --git a/examples/clock/src/toppage_handler.erl b/examples/clock/src/toppage_handler.erl
index 66c8400..ee482a6 100644
--- a/examples/clock/src/toppage_handler.erl
+++ b/examples/clock/src/toppage_handler.erl
@@ -5,7 +5,7 @@
-export([init/3]).
-export([handle/2]).
--export([terminate/2]).
+-export([terminate/3]).
init(_Transport, Req, []) ->
{ok, Req, undefined}.
@@ -52,9 +52,9 @@ $(document).ready(function(){
</body>
</html>
">>,
- {ok, Req2} = cowboy_http_req:reply(200, [{'Content-Type', <<"text/html">>}],
+ {ok, Req2} = cowboy_req:reply(200, [{<<"content-type">>, <<"text/html">>}],
Body, Req),
{ok, Req2, State}.
-terminate(_Req, _State) ->
+terminate(_Reason, _Req, _State) ->
ok.