Skip to content
Browse files

Fix handlers and return value of rw_resource example

  • Loading branch information...
1 parent 36c9cab commit 09dc127774de1db1aa2debb0366cd12845e83f2a @lafka committed
Showing with 5 additions and 4 deletions.
  1. +4 −3 examples/rw_resource/src/fallback_handler.erl
  2. +1 −1 examples/rw_resource/src/resource_handler.erl
View
7 examples/rw_resource/src/fallback_handler.erl
@@ -8,11 +8,12 @@
handlers(_Req) ->
Handler = handle_404,
- [{'HEAD', Handler}, {'GET', Handler},
- {'POST', Handler}, {'PATCH', Handler}].
+ [{'HEAD', Handler}, {'GET', Handler},
+ {'POST', Handler}, {'PUT', Handler},
+ {'PATCH', Handler}, {'OPTIONS', handle_default_options}].
methods(_Req) ->
- ['HEAD', 'GET', 'POST', 'PUT', 'PATCH'].
+ ['HEAD', 'GET', 'POST', 'PUT', 'PATCH', 'OPTIONS'].
handle_404(Req, State) ->
{'Not Found', Req, State, [{error, [{message, <<"resource not found">>}, {code, 404}]}]}.
View
2 examples/rw_resource/src/resource_handler.erl
@@ -19,7 +19,7 @@ provides(_Req) ->
handle_get(Req, State) ->
{ID, Req} = cowboy_http_req:binding(id, Req),
- {'Ok', Req, State, [{result, [{message, <<"fetch: ", ID/binary>>}]}]}.
+ {'OK', Req, State, [{result, [{message, <<"fetch: ", ID/binary>>}]}]}.
handle_put(Req, #tavern{body = _Body} = State) ->
{ID, Req} = cowboy_http_req:binding(id, Req),

0 comments on commit 09dc127

Please sign in to comment.
Something went wrong with that request. Please try again.