| 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 |
|
| 5 |
-module(charsets_provided_empty_h). |
| 6 |
|
| 7 |
-export([init/2]). |
| 8 |
-export([content_types_provided/2]). |
| 9 |
-export([charsets_provided/2]). |
| 10 |
-export([get_text_plain/2]). |
| 11 |
-export([get_application_json/2]). |
| 12 |
|
| 13 |
init(Req, Opts) -> |
| 14 |
{cowboy_rest, Req, Opts}. |
| 15 |
|
| 16 |
content_types_provided(Req, State) -> |
| 17 |
{[ |
| 18 |
{{<<"text">>, <<"plain">>, []}, get_text_plain}, |
| 19 |
{{<<"application">>, <<"json">>, []}, get_application_json} |
| 20 |
], Req, State}. |
| 21 |
|
| 22 |
charsets_provided(Req, State) -> |
| 23 |
{[], Req, State}. |
| 24 |
|
| 25 |
get_text_plain(Req, State) -> |
| 26 |
{<<"This is REST!">>, Req, State}. |
| 27 |
|
| 28 |
get_application_json(Req, State) -> |
| 29 |
{<<"{\"hello\": \"rest\"}">>, Req, State}. |
| 30 |
|