From e1aa5deeede89e83a21611d2d669ef282b3c570f Mon Sep 17 00:00:00 2001 From: Myers Carpenter Date: Wed, 12 Feb 2014 09:52:55 -0500 Subject: [PATCH 1/2] bump to using cowboy 0.9.0 --- rebar.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rebar.config b/rebar.config index 03f63bb..0117880 100644 --- a/rebar.config +++ b/rebar.config @@ -11,5 +11,5 @@ ]}. {deps, [ - {cowboy, "0.8.3",{git, "https://github.com/extend/cowboy.git", "0.8.3"}} + {cowboy, "0.9.0",{git, "https://github.com/extend/cowboy.git", "0.9.0"}} ]}. From 4bffe6d4b594a2bc71059d5f0a702d7d278108b5 Mon Sep 17 00:00:00 2001 From: Myers Carpenter Date: Thu, 13 Feb 2014 09:33:06 -0500 Subject: [PATCH 2/2] update sample apps to work with cowboy 0.9.0 --- examples/cowboy_echo.erl | 21 ++------------------- examples/cowboy_test_server.erl | 1 + 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/examples/cowboy_echo.erl b/examples/cowboy_echo.erl index ac18843..4153cd8 100755 --- a/examples/cowboy_echo.erl +++ b/examples/cowboy_echo.erl @@ -5,23 +5,20 @@ -export([main/1]). -%% Cowboy callbacks --export([init/3, handle/2, terminate/3]). - - main(_) -> Port = 8081, ok = application:start(xmerl), ok = application:start(sockjs), ok = application:start(ranch), ok = application:start(crypto), + ok = application:start(cowlib), ok = application:start(cowboy), SockjsState = sockjs_handler:init_state( <<"/echo">>, fun service_echo/3, state, []), VhostRoutes = [{<<"/echo/[...]">>, sockjs_cowboy_handler, SockjsState}, - {'_', ?MODULE, []}], + {"/", cowboy_static, {file, "./examples/echo.html"}}], Routes = [{'_', VhostRoutes}], % any vhost Dispatch = cowboy_router:compile(Routes), @@ -35,20 +32,6 @@ main(_) -> %% -------------------------------------------------------------------------- -init({_Any, http}, Req, []) -> - {ok, Req, []}. - -handle(Req, State) -> - {ok, Data} = file:read_file("./examples/echo.html"), - {ok, Req1} = cowboy_req:reply(200, [{<<"Content-Type">>, "text/html"}], - Data, Req), - {ok, Req1, State}. - -terminate(_Reason, _Req, _State) -> - ok. - -%% -------------------------------------------------------------------------- - service_echo(_Conn, init, state) -> {ok, state}; service_echo(Conn, {recv, Data}, state) -> Conn:send(Data); service_echo(_Conn, {info, _Info}, state) -> {ok, state}; diff --git a/examples/cowboy_test_server.erl b/examples/cowboy_test_server.erl index c7396e5..171573f 100755 --- a/examples/cowboy_test_server.erl +++ b/examples/cowboy_test_server.erl @@ -15,6 +15,7 @@ main(_) -> ok = application:start(sockjs), ok = application:start(ranch), ok = application:start(crypto), + ok = application:start(cowlib), ok = application:start(cowboy), StateEcho = sockjs_handler:init_state(