Format code

This commit is contained in:
turtled 2017-05-19 10:22:07 +08:00
parent 9c5ce15f46
commit 96562dfc59
1 changed files with 5 additions and 4 deletions

View File

@ -88,8 +88,7 @@ handle_request(Method, Path, Req) ->
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
http_publish(Req) -> http_publish(Req) ->
Params0 = mochiweb_request:parse_post(Req), Params = [{iolist_to_binary(Key), Val} || {Key, Val} <- mochiweb_request:parse_post(Req)],
Params = [{iolist_to_binary(Key), Val} || {Key, Val} <- Params0],
lager:info("HTTP Publish: ~p", [Params]), lager:info("HTTP Publish: ~p", [Params]),
Topics = topics(Params), Topics = topics(Params),
ClientId = get_value(<<"client">>, Params, http), ClientId = get_value(<<"client">>, Params, http),
@ -152,13 +151,15 @@ authorized(Req) ->
user_passwd(BasicAuth) -> user_passwd(BasicAuth) ->
list_to_tuple(binary:split(base64:decode(BasicAuth), <<":">>)). list_to_tuple(binary:split(base64:decode(BasicAuth), <<":">>)).
int(S) when is_integer(S)-> S; int(I) when is_integer(I)-> I;
int(S) -> list_to_integer(S). int(S) -> list_to_integer(S).
bool(0) -> false; bool(0) -> false;
bool(1) -> true; bool(1) -> true;
bool("0") -> false; bool("0") -> false;
bool("1") -> true. bool("1") -> true;
bool(<<"0">>) -> false;
bool(<<"1">>) -> true.
is_websocket(Upgrade) -> is_websocket(Upgrade) ->
Upgrade =/= undefined andalso string:to_lower(Upgrade) =:= "websocket". Upgrade =/= undefined andalso string:to_lower(Upgrade) =:= "websocket".