0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-16 05:00:24 +00:00
cowboy/test/http_SUITE_data/http_req_attr.erl

16 lines
450 B
Erlang
Raw Normal View History

2013-08-25 02:13:53 +09:00
%% Feel free to use, reuse and abuse the code in this file.
%% @todo That module was clearly meant to do more than one
%% thing and yet doesn't.
2013-08-25 02:13:53 +09:00
-module(http_req_attr).
-export([init/2]).
init(Req, Opts) ->
#{attr := Attr} = cowboy_req:match_qs(Req, [attr]),
<<"host_and_port">> = Attr,
Host = cowboy_req:host(Req),
Port = cowboy_req:port(Req),
2013-08-25 02:13:53 +09:00
Value = [Host, "\n", integer_to_list(Port)],
{ok, cowboy_req:reply(200, [], Value, Req), Opts}.