aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_http_rest.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2012-01-09 08:06:05 +0100
committerLoïc Hoguin <[email protected]>2012-01-09 08:06:05 +0100
commitfed6727634fb1db092c38ad53940007fc27d6edb (patch)
treeea35c508a1b9b657767b641fd4fefcd80a353878 /src/cowboy_http_rest.erl
parent348e22589ee0d7bfb89f7eba1ef32cac3513129f (diff)
downloadcowboy-fed6727634fb1db092c38ad53940007fc27d6edb.tar.gz
cowboy-fed6727634fb1db092c38ad53940007fc27d6edb.tar.bz2
cowboy-fed6727634fb1db092c38ad53940007fc27d6edb.zip
Make REST handlers' put_resource accept true or false return values
Followup to 0bb23f2400ed0b65834913c8522a978d986f1f92. As discussed in #119.
Diffstat (limited to 'src/cowboy_http_rest.erl')
-rw-r--r--src/cowboy_http_rest.erl7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/cowboy_http_rest.erl b/src/cowboy_http_rest.erl
index 63d15ff..35f82e3 100644
--- a/src/cowboy_http_rest.erl
+++ b/src/cowboy_http_rest.erl
@@ -711,9 +711,12 @@ choose_content_type(Req, State, _OnTrue, _ContentType, []) ->
choose_content_type(Req, State, OnTrue, ContentType,
[{Accepted, Fun}|_Tail]) when ContentType =:= Accepted ->
case call(Req, State, Fun) of
- {ok, Req2, HandlerState} ->
+ {true, Req2, HandlerState} ->
+ State2 = State#state{handler_state=HandlerState},
+ next(Req2, State2, OnTrue);
+ {false, Req2, HandlerState} ->
State2 = State#state{handler_state=HandlerState},
- next(Req2, State2, OnTrue)
+ respond(Req2, State2, 500)
end;
choose_content_type(Req, State, OnTrue, ContentType, [_Any|Tail]) ->
choose_content_type(Req, State, OnTrue, ContentType, Tail).