diff options
author | Ali Sabil <[email protected]> | 2012-03-21 09:46:10 +0100 |
---|---|---|
committer | Ali Sabil <[email protected]> | 2012-03-21 09:46:10 +0100 |
commit | 98c58280f6bb8b21537e372e07aa972f6d35b4d7 (patch) | |
tree | f1c8eb89954b8c1159e4970d694df0bbc9d86b49 /src | |
parent | 7e745824324187ed7b4559bc7c4eb6e40e87567c (diff) | |
download | cowboy-98c58280f6bb8b21537e372e07aa972f6d35b4d7.tar.gz cowboy-98c58280f6bb8b21537e372e07aa972f6d35b4d7.tar.bz2 cowboy-98c58280f6bb8b21537e372e07aa972f6d35b4d7.zip |
Simplify the options filtering code in cowboy_ssl_transport
Diffstat (limited to 'src')
-rw-r--r-- | src/cowboy_ssl_transport.erl | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/src/cowboy_ssl_transport.erl b/src/cowboy_ssl_transport.erl index ccd8e5a..92a231c 100644 --- a/src/cowboy_ssl_transport.erl +++ b/src/cowboy_ssl_transport.erl @@ -67,30 +67,17 @@ listen(Opts) -> {port, Port} = lists:keyfind(port, 1, Opts), Backlog = proplists:get_value(backlog, Opts, 1024), {certfile, CertFile} = lists:keyfind(certfile, 1, Opts), - KeyFileOpts = - case lists:keyfind(keyfile, 1, Opts) of - false -> []; - KeyFile -> [KeyFile] - end, - PasswordOpts = - case lists:keyfind(password, 1, Opts) of - false -> []; - Password -> [Password] - end, + ListenOpts0 = [binary, {active, false}, {backlog, Backlog}, {packet, raw}, {reuseaddr, true}, {certfile, CertFile}], - ListenOpts1 = - case lists:keyfind(ip, 1, Opts) of - false -> ListenOpts0; - Ip -> [Ip|ListenOpts0] - end, - ListenOpts2 = - case lists:keyfind(cacertfile, 1, Opts) of - false -> ListenOpts1; - CACertFile -> [CACertFile|ListenOpts1] - end, - ListenOpts = ListenOpts2 ++ KeyFileOpts ++ PasswordOpts, + ListenOpts = lists:foldl(fun + ({ip, _} = Ip, Acc) -> [Ip | Acc]; + ({keyfile, _} = KeyFile, Acc) -> [KeyFile | Acc]; + ({password, _} = Password, Acc) -> [Password | Acc]; + ({cacertfile, _} = CACertFile, Acc) -> [CACertFile | Acc]; + (_, Acc) -> Acc + end, ListenOpts0, Opts), ssl:listen(Port, ListenOpts). %% @doc Accept an incoming connection on a listen socket. |