0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-15 04:30:25 +00:00

Convert the SSL hello world example to a release

This commit is contained in:
Loïc Hoguin 2013-09-08 20:17:25 +02:00
parent 1f8119ef31
commit 24a22fa657
9 changed files with 42 additions and 40 deletions

View file

@ -8,7 +8,8 @@
{applications, [
kernel,
stdlib,
cowboy
cowboy,
ssl
]},
{mod, {ssl_hello_world_app, []}},
{env, []}

View file

@ -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).

View file

@ -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().

View file

@ -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) ->