Browse Source

Fix hello_world example

Loïc Hoguin 9 years ago
parent
commit
ff936ff0ee

+ 3 - 3
examples/hello_world/src/hello_world_app.erl

@@ -16,9 +16,9 @@ start(_Type, _Args) ->
 			{"/", toppage_handler, []}
 		]}
 	]),
-	{ok, _} = cowboy:start_http(http, 100, [{port, 8080}], [
-		{env, [{dispatch, Dispatch}]}
-	]),
+	{ok, _} = cowboy:start_clear(http, 100, [{port, 8080}], #{
+		env => #{dispatch => Dispatch}
+	}),
 	hello_world_sup:start_link().
 
 stop(_State) ->

+ 4 - 4
examples/hello_world/src/toppage_handler.erl

@@ -6,7 +6,7 @@
 -export([init/2]).
 
 init(Req, Opts) ->
-	Req2 = cowboy_req:reply(200, [
-		{<<"content-type">>, <<"text/plain">>}
-	], <<"Hello world!">>, Req),
-	{ok, Req2, Opts}.
+	cowboy_req:reply(200, #{
+		<<"content-type">> => <<"text/plain">>
+	}, <<"Hello world!">>, Req),
+	{ok, Req, Opts}.