| 1 |
%% This module returns something different in |
| 2 |
%% AcceptCallback depending on the query string. |
| 3 |
|
| 4 |
-module(accept_callback_h). |
| 5 |
|
| 6 |
-export([init/2]). |
| 7 |
-export([allowed_methods/2]). |
| 8 |
-export([content_types_accepted/2]). |
| 9 |
-export([put_text_plain/2]). |
| 10 |
|
| 11 |
init(Req, Opts) -> |
| 12 |
{cowboy_rest, Req, Opts}. |
| 13 |
|
| 14 |
allowed_methods(Req, State) -> |
| 15 |
{[<<"PUT">>, <<"POST">>, <<"PATCH">>], Req, State}. |
| 16 |
|
| 17 |
content_types_accepted(Req, State) -> |
| 18 |
{[{{<<"text">>, <<"plain">>, []}, put_text_plain}], Req, State}. |
| 19 |
|
| 20 |
put_text_plain(Req=#{qs := <<"false">>}, State) -> |
| 21 |
{false, Req, State}; |
| 22 |
put_text_plain(Req=#{qs := <<"true">>}, State) -> |
| 23 |
{true, Req, State}. |