mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Automatically start crypto, public_key and ssl if needed.
Following mochiweb and misultin's example here even though I'm not too thrilled about starting them and not stopping but it's optional and the application's author can start/stop them as normal anyway.
This commit is contained in:
parent
4c4030a792
commit
0720d6b9e3
1 changed files with 11 additions and 0 deletions
|
@ -30,6 +30,7 @@ messages() -> {ssl, ssl_closed, ssl_error}.
|
||||||
| {keyfile, KeyPath::string()} | {password, Password::string()}])
|
| {keyfile, KeyPath::string()} | {password, Password::string()}])
|
||||||
-> {ok, LSocket::ssl:sslsocket()} | {error, Reason::atom()}.
|
-> {ok, LSocket::ssl:sslsocket()} | {error, Reason::atom()}.
|
||||||
listen(Opts) ->
|
listen(Opts) ->
|
||||||
|
require([crypto, public_key, ssl]),
|
||||||
{port, Port} = lists:keyfind(port, 1, Opts),
|
{port, Port} = lists:keyfind(port, 1, Opts),
|
||||||
Backlog = proplists:get_value(backlog, Opts, 1024),
|
Backlog = proplists:get_value(backlog, Opts, 1024),
|
||||||
{certfile, CertFile} = lists:keyfind(certfile, 1, Opts),
|
{certfile, CertFile} = lists:keyfind(certfile, 1, Opts),
|
||||||
|
@ -80,6 +81,16 @@ close(Socket) ->
|
||||||
|
|
||||||
%% Internal.
|
%% Internal.
|
||||||
|
|
||||||
|
-spec require(Apps::list(module())) -> ok.
|
||||||
|
require([]) ->
|
||||||
|
ok;
|
||||||
|
require([App|Tail]) ->
|
||||||
|
case application:start(App) of
|
||||||
|
ok -> ok;
|
||||||
|
{error, {already_started, App}} -> ok
|
||||||
|
end,
|
||||||
|
require(Tail).
|
||||||
|
|
||||||
-spec ssl_accept(CSocket::ssl:sslsocket(), Timeout::timeout())
|
-spec ssl_accept(CSocket::ssl:sslsocket(), Timeout::timeout())
|
||||||
-> {ok, Socket::ssl:sslsocket()} | {error, Reason::closed | timeout | atom()}.
|
-> {ok, Socket::ssl:sslsocket()} | {error, Reason::closed | timeout | atom()}.
|
||||||
ssl_accept(CSocket, Timeout) ->
|
ssl_accept(CSocket, Timeout) ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue