Debian Codegraph @

doc/src/manual/cowboy_req.port.asciidoc

raw
1 = cowboy_req:port(3)
2
3 == Name
4
5 cowboy_req:port - URI port number
6
7 == Description
8
9 [source,erlang]
10 ----
11 port(Req :: cowboy_req:req()) -> Port :: inet:port_number()
12 ----
13
14 Return the port number of the effective request URI.
15
16 Note that the port number returned by this function is obtained
17 by parsing the host header. It may be different from the port
18 the peer used to connect to Cowboy.
19
20 The port number can also be obtained using pattern matching:
21
22 [source,erlang]
23 ----
24 #{port := Port} = Req.
25 ----
26
27 == Arguments
28
29 Req::
30
31 The Req object.
32
33 == Return value
34
35 The port number is returned as an integer.
36
37 == Changelog
38
39 * *2.0*: Only the port number is returned, it is no longer wrapped in a tuple.
40 * *1.0*: Function introduced.
41
42 == Examples
43
44 .Get the effective request URI's port number
45 [source,erlang]
46 ----
47 Port = cowboy_req:port(Req).
48 ----
49
50 == See also
51
52 link:man:cowboy_req(3)[cowboy_req(3)]