cowboy_req.port.asciidoc 886 B

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