From 24a22fa657af8398c963889d0bf08a904c96ec8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sun, 8 Sep 2013 20:17:25 +0200 Subject: Convert the SSL hello world example to a release --- examples/ssl_hello_world/src/ssl_hello_world.app.src | 3 ++- examples/ssl_hello_world/src/ssl_hello_world.erl | 15 --------------- examples/ssl_hello_world/src/ssl_hello_world_app.erl | 7 ++++--- examples/ssl_hello_world/src/toppage_handler.erl | 4 +++- 4 files changed, 9 insertions(+), 20 deletions(-) delete mode 100644 examples/ssl_hello_world/src/ssl_hello_world.erl (limited to 'examples/ssl_hello_world/src') diff --git a/examples/ssl_hello_world/src/ssl_hello_world.app.src b/examples/ssl_hello_world/src/ssl_hello_world.app.src index 514da1c..d628b68 100644 --- a/examples/ssl_hello_world/src/ssl_hello_world.app.src +++ b/examples/ssl_hello_world/src/ssl_hello_world.app.src @@ -8,7 +8,8 @@ {applications, [ kernel, stdlib, - cowboy + cowboy, + ssl ]}, {mod, {ssl_hello_world_app, []}}, {env, []} diff --git a/examples/ssl_hello_world/src/ssl_hello_world.erl b/examples/ssl_hello_world/src/ssl_hello_world.erl deleted file mode 100644 index 83c250e..0000000 --- a/examples/ssl_hello_world/src/ssl_hello_world.erl +++ /dev/null @@ -1,15 +0,0 @@ -%% Feel free to use, reuse and abuse the code in this file. - --module(ssl_hello_world). - -%% 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(ssl_hello_world). diff --git a/examples/ssl_hello_world/src/ssl_hello_world_app.erl b/examples/ssl_hello_world/src/ssl_hello_world_app.erl index ae8f0cf..3e53818 100644 --- a/examples/ssl_hello_world/src/ssl_hello_world_app.erl +++ b/examples/ssl_hello_world/src/ssl_hello_world_app.erl @@ -16,11 +16,12 @@ start(_Type, _Args) -> {"/", toppage_handler, []} ]} ]), + PrivDir = code:priv_dir(ssl_hello_world), {ok, _} = cowboy:start_https(https, 100, [ {port, 8443}, - {cacertfile, "priv/ssl/cowboy-ca.crt"}, - {certfile, "priv/ssl/server.crt"}, - {keyfile, "priv/ssl/server.key"} + {cacertfile, PrivDir ++ "/ssl/cowboy-ca.crt"}, + {certfile, PrivDir ++ "/ssl/server.crt"}, + {keyfile, PrivDir ++ "/ssl/server.key"} ], [{env, [{dispatch, Dispatch}]}]), ssl_hello_world_sup:start_link(). diff --git a/examples/ssl_hello_world/src/toppage_handler.erl b/examples/ssl_hello_world/src/toppage_handler.erl index 4124b5a..f0fa806 100644 --- a/examples/ssl_hello_world/src/toppage_handler.erl +++ b/examples/ssl_hello_world/src/toppage_handler.erl @@ -11,7 +11,9 @@ init(_Transport, Req, []) -> {ok, Req, undefined}. handle(Req, State) -> - {ok, Req2} = cowboy_req:reply(200, [], <<"Hello world!">>, Req), + {ok, Req2} = cowboy_req:reply(200, [ + {<<"content-type">>, <<"text/plain">>} + ], <<"Hello world!">>, Req), {ok, Req2, State}. terminate(_Reason, _Req, _State) -> -- cgit v1.2.3