diff options
author | Linus Nordberg <linus@nordu.net> | 2015-11-13 14:33:49 +0100 |
---|---|---|
committer | Linus Nordberg <linus@nordu.net> | 2015-11-13 14:46:50 +0100 |
commit | ce66c555c35e17c1ca0e0b4ff28056526183fceb (patch) | |
tree | 11a3999316dca8728afd990135313efaa7028958 | |
parent | 65cfc5397062db367ad537ccf4bf09cd7ddcf096 (diff) |
Whitespace.
-rw-r--r-- | src/catlfish_sup.erl | 9 | ||||
-rw-r--r-- | src/catlfish_web.erl | 33 |
2 files changed, 26 insertions, 16 deletions
diff --git a/src/catlfish_sup.erl b/src/catlfish_sup.erl index 353b691..8b43faf 100644 --- a/src/catlfish_sup.erl +++ b/src/catlfish_sup.erl @@ -21,18 +21,17 @@ permanent_worker(Name, StartFunc, Modules) -> gen_http_config(Config, SSLOptions, SSLFlag) -> {ChildName, IpAddress, Port, Module} = Config, - {ok, IPv4Address} = - inet:parse_ipv4strict_address(IpAddress), + {ok, IPv4Address} = inet:parse_ipv4strict_address(IpAddress), WebConfig = [{ip, IPv4Address}, {port, Port}, {ssl, SSLFlag}, - {acceptor_pool_size, application:get_env(catlfish, http_server_pool_size, 16)}, + {acceptor_pool_size, + application:get_env(catlfish, http_server_pool_size, 16)}, {ssl_opts, SSLOptions} ], {ChildName, {catlfish_web, start, [WebConfig, Module, ChildName]}, - permanent, 5000, - worker, dynamic}. + permanent, 5000, worker, dynamic}. init([]) -> SSLOptions = diff --git a/src/catlfish_web.erl b/src/catlfish_web.erl index d49aaa1..e541a9b 100644 --- a/src/catlfish_web.erl +++ b/src/catlfish_web.erl @@ -26,39 +26,49 @@ loop(Req, Module) -> 'GET' -> Query = Req:parse_qs(), {_, RawQuery, _} = mochiweb_util:urlsplit_path(Req:get(raw_path)), - Result = case http_auth:verify_auth(AuthHeader, "GET", "/" ++ Path, RawQuery) of + Result = case http_auth:verify_auth(AuthHeader, "GET", + "/" ++ Path, RawQuery) of failure -> - {403, [{"Content-Type", "text/plain"}], "Invalid credentials"}; + {403, [{"Content-Type", "text/plain"}], + "Invalid credentials"}; success -> lager:debug("GET ~p ~p", [Path, Query]), - add_auth("/" ++ Path, Module:request(get, Path, Query)); + add_auth("/" ++ Path, + Module:request(get, Path, Query)); noauth -> lager:debug("GET ~p ~p", [Path, Query]), Module:request(get, Path, Query) end, - lager:debug("GET finished: ~p us", [timer:now_diff(os:timestamp(), Starttime)]), + lager:debug("GET finished: ~p us", + [timer:now_diff(os:timestamp(), Starttime)]), case Result of none -> - Req:respond({404, [{"Content-Type", "text/plain"}], "Page not found"}); + Req:respond({404, [{"Content-Type", "text/plain"}], + "Page not found"}); _ -> Req:respond(Result) end; 'POST' -> Body = Req:recv_body(), - Result = case http_auth:verify_auth(AuthHeader, "POST", "/" ++ Path, Body) of + Result = case http_auth:verify_auth(AuthHeader, "POST", + "/" ++ Path, Body) of failure -> - {403, [{"Content-Type", "text/plain"}], "Invalid credentials"}; + {403, [{"Content-Type", "text/plain"}], + "Invalid credentials"}; success -> lager:debug("POST ~p ~p", [Path, Body]), - add_auth("/" ++ Path, Module:request(post, Path, Body)); + add_auth("/" ++ Path, + Module:request(post, Path, Body)); noauth -> lager:debug("POST ~p ~p", [Path, Body]), Module:request(post, Path, Body) end, - lager:debug("POST finished: ~p us", [timer:now_diff(os:timestamp(), Starttime)]), + lager:debug("POST finished: ~p us", + [timer:now_diff(os:timestamp(), Starttime)]), case Result of none -> - Req:respond({404, [{"Content-Type", "text/plain"}], "Page not found"}); + Req:respond({404, [{"Content-Type", "text/plain"}], + "Page not found"}); _ -> Req:respond(Result) end; @@ -68,7 +78,8 @@ loop(Req, Module) -> catch Type:What -> [CrashFunction | Stack] = erlang:get_stacktrace(), - lager:error("Crash in ~p for path ~p: ~p ~p~n~p~n~p~n", [Module, Path, Type, What, CrashFunction, Stack]), + lager:error("Crash in ~p for path ~p: ~p ~p~n~p~n~p~n", + [Module, Path, Type, What, CrashFunction, Stack]), Req:respond({500, [{"Content-Type", "text/plain"}], "Internal Server Error\n"}) end. |