http_req_attr.erl 450 B

123456789101112131415
  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. init(Req, Opts) ->
  7. #{attr := Attr} = cowboy_req:match_qs(Req, [attr]),
  8. <<"host_and_port">> = Attr,
  9. Host = cowboy_req:host(Req),
  10. Port = cowboy_req:port(Req),
  11. Value = [Host, "\n", integer_to_list(Port)],
  12. {ok, cowboy_req:reply(200, [], Value, Req), Opts}.