rest_missing_callbacks.erl 619 B

1234567891011121314151617181920212223
  1. -module(rest_missing_callbacks).
  2. -export([init/3]).
  3. -export([allowed_methods/2]).
  4. -export([content_types_accepted/2]).
  5. -export([content_types_provided/2]).
  6. init(_Transport, _Req, _Opts) ->
  7. {upgrade, protocol, cowboy_rest}.
  8. allowed_methods(Req, State) ->
  9. {[<<"GET">>, <<"PUT">>], Req, State}.
  10. content_types_accepted(Req, State) ->
  11. cowboy_error_h:ignore(cowboy_rest, process_content_type, 3),
  12. {[
  13. {<<"application/json">>, put_application_json}
  14. ], Req, State}.
  15. content_types_provided(Req, State) ->
  16. cowboy_error_h:ignore(cowboy_rest, set_resp_body, 2),
  17. {[
  18. {<<"text/plain">>, get_text_plain}
  19. ], Req, State}.