Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Commit

Permalink
bin/load reads LOGPLEX_AUTH_KEY correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
jkvor committed Jan 24, 2012
1 parent b8bcd23 commit 34e2ece
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions bin/load
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ main([]) ->
main(Modules) ->
application:start(inets),
JSON = iolist_to_binary(mochijson2:encode([list_to_binary(Module) || Module <- Modules])),
{match, [Auth]} = re:run(Body, "export LOGPLEX_AUTH_KEY='(\\S+)'", [{capture, all_but_first, binary}]),
{ok, File} = file:read_file("keys.sh"),
{match, [Auth]} = re:run(File, "export LOGPLEX_AUTH_KEY='(\\S+)'", [{capture, all_but_first, binary}]),
Headers = [
{'Authorization', Auth}
{"Authorization", Auth}
],
case httpc:request(post, {"http://localhost:8001/load", Headers, "application/json", JSON}, [], []) of
{ok, {{_, 200, _}, _, Body}} ->
Expand Down
2 changes: 1 addition & 1 deletion src/logplex_api.erl
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ handlers() ->
{['POST', "/load$"], fun(Req, _Match) ->
authorize(Req),
Body = Req:recv_body(),
{struct, Modules} = mochijson2:decode(Body),
Modules = mochijson2:decode(Body),
not is_list(Modules) andalso exit({expected_list}),

{RespCode, Json} = lists:foldl(fun(Module, {Code, Acc}) ->
Expand Down

0 comments on commit 34e2ece

Please sign in to comment.