asterisk_h.erl 394 B

12345678910111213141516
  1. %% This module echoes back the value the test is interested in.
  2. -module(asterisk_h).
  3. -export([init/2]).
  4. init(Req, Opts) ->
  5. echo(cowboy_req:header(<<"x-echo">>, Req), Req, Opts).
  6. echo(What, Req, Opts) ->
  7. F = binary_to_atom(What, latin1),
  8. Value = case cowboy_req:F(Req) of
  9. V when is_integer(V) -> integer_to_binary(V);
  10. V -> V
  11. end,
  12. {ok, cowboy_req:reply(200, #{}, Value, Req), Opts}.