0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-15 12:40:25 +00:00

Make REST handlers' put_resource accept true or false return values

Followup to 0bb23f2400.
As discussed in #119.
This commit is contained in:
Loïc Hoguin 2012-01-09 08:06:05 +01:00
parent 348e22589e
commit fed6727634

View file

@ -711,9 +711,12 @@ choose_content_type(Req, State, _OnTrue, _ContentType, []) ->
choose_content_type(Req, State, OnTrue, ContentType, choose_content_type(Req, State, OnTrue, ContentType,
[{Accepted, Fun}|_Tail]) when ContentType =:= Accepted -> [{Accepted, Fun}|_Tail]) when ContentType =:= Accepted ->
case call(Req, State, Fun) of case call(Req, State, Fun) of
{ok, Req2, HandlerState} -> {true, Req2, HandlerState} ->
State2 = State#state{handler_state=HandlerState}, State2 = State#state{handler_state=HandlerState},
next(Req2, State2, OnTrue) next(Req2, State2, OnTrue);
{false, Req2, HandlerState} ->
State2 = State#state{handler_state=HandlerState},
respond(Req2, State2, 500)
end; end;
choose_content_type(Req, State, OnTrue, ContentType, [_Any|Tail]) -> choose_content_type(Req, State, OnTrue, ContentType, [_Any|Tail]) ->
choose_content_type(Req, State, OnTrue, ContentType, Tail). choose_content_type(Req, State, OnTrue, ContentType, Tail).