http_req_attr.erl 515 B

12345678910111213141516171819
  1. %% Feel free to use, reuse and abuse the code in this file.
  2. %% @todo That module was clearly meant to do more than one
  3. %% thing and yet doesn't.
  4. -module(http_req_attr).
  5. -export([init/2]).
  6. -export([handle/2]).
  7. init(Req, Opts) ->
  8. {http, Req, Opts}.
  9. handle(Req, State) ->
  10. #{attr := Attr} = cowboy_req:match_qs(Req, [attr]),
  11. <<"host_and_port">> = Attr,
  12. Host = cowboy_req:host(Req),
  13. Port = cowboy_req:port(Req),
  14. Value = [Host, "\n", integer_to_list(Port)],
  15. {ok, cowboy_req:reply(200, [], Value, Req), State}.