Debian Codegraph @

test/handlers/charsets_provided_h.erl

raw
1 %% This module has a text and non-text media type,
2 %% and provides two charsets.
3
4 -module(charsets_provided_h).
5
6 -export([init/2]).
7 -export([content_types_provided/2]).
8 -export([charsets_provided/2]).
9 -export([get_text_plain/2]).
10 -export([get_application_json/2]).
11
12 init(Req, Opts) ->
13 {cowboy_rest, Req, Opts}.
14
15 content_types_provided(Req, State) ->
16 {[
17 {{<<"text">>, <<"plain">>, []}, get_text_plain},
18 {{<<"application">>, <<"json">>, []}, get_application_json}
19 ], Req, State}.
20
21 charsets_provided(Req, State) ->
22 {[<<"utf-8">>, <<"utf-16">>], Req, State}.
23
24 get_text_plain(Req, State) ->
25 {<<"This is REST!">>, Req, State}.
26
27 get_application_json(Req, State) ->
28 {<<"{\"hello\": \"rest\"}">>, Req, State}.