charsets_provided_empty_h.erl 744 B

123456789101112131415161718192021222324252627282930
  1. %% This module has a text and non-text media type,
  2. %% but provides no charset. All requests will result
  3. %% in a 406 not acceptable.
  4. -module(charsets_provided_empty_h).
  5. -export([init/2]).
  6. -export([content_types_provided/2]).
  7. -export([charsets_provided/2]).
  8. -export([get_text_plain/2]).
  9. -export([get_application_json/2]).
  10. init(Req, Opts) ->
  11. {cowboy_rest, Req, Opts}.
  12. content_types_provided(Req, State) ->
  13. {[
  14. {{<<"text">>, <<"plain">>, []}, get_text_plain},
  15. {{<<"application">>, <<"json">>, []}, get_application_json}
  16. ], Req, State}.
  17. charsets_provided(Req, State) ->
  18. {[], Req, State}.
  19. get_text_plain(Req, State) ->
  20. {<<"This is REST!">>, Req, State}.
  21. get_application_json(Req, State) ->
  22. {<<"{\"hello\": \"rest\"}">>, Req, State}.