rest_missing_callbacks.erl 604 B

123456789101112131415161718192021222324
  1. -module(rest_missing_callbacks).
  2. -export([init/2]).
  3. -export([allowed_methods/2]).
  4. -export([content_types_accepted/2]).
  5. -export([content_types_provided/2]).
  6. init(Req, Opts) ->
  7. {cowboy_rest, Req, Opts}.
  8. allowed_methods(Req, State) ->
  9. {[<<"GET">>, <<"PUT">>], Req, State}.
  10. content_types_accepted(Req, State) ->
  11. ct_helper_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. ct_helper_error_h:ignore(cowboy_rest, set_resp_body, 2),
  17. {[
  18. {<<"text/plain">>, get_text_plain}
  19. ], Req, State}.