Skip to content

Commit

Permalink
Making teh Rubies happy
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Smith committed Sep 6, 2012
1 parent cb9999d commit 86c27a9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/crest_value_resource.erl
Expand Up @@ -76,7 +76,9 @@ process_post(Req, #state{valueref=ValueRef, action={write, Value}, expects=Expec
true ->
case crest_values:get(ValueRef, Value) of
created ->
{true, Req, State};
Json = {[{<<"name">>, ValueRef}, {<<"value">>, Value}]},
Req1 = wrq:append_to_response_body(jiffy:encode(Json), Req),
{true, Req1, State};
exists ->
{{halt, 409}, Req, State}
end;
Expand Down Expand Up @@ -113,14 +115,14 @@ delete_resource(Req, #state{valueref=ValueRef}=State) ->
{true, Req, State}.

validate_body(Action, Req, #state{expects=Expects}) when Action == 'POST';
Action == 'PUT' ->
Action == 'PUT' ->
case wrq:req_body(Req) of
"" ->
error;
Body ->
case catch jiffy:decode(Body) of
{error, Reason} ->
lager:error("Error decoding JSON: ~p ~p~n", [Body, Reason]),
lager:error("Error parsing ~p: ~p~n", [Body, Reason]),
error;
{DecodedBody} ->
translate_write(DecodedBody, Expects)
Expand Down

0 comments on commit 86c27a9

Please sign in to comment.