mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-15 12:40:25 +00:00
Introduce cowboy_req:sock/1 and cowboy_req:cert/1
To obtain the local socket ip/port and the client TLS certificate, respectively.
This commit is contained in:
parent
4090adaecc
commit
ef58e15547
9 changed files with 268 additions and 35 deletions
51
doc/src/manual/cowboy_req.sock.asciidoc
Normal file
51
doc/src/manual/cowboy_req.sock.asciidoc
Normal file
|
@ -0,0 +1,51 @@
|
|||
= cowboy_req:sock(3)
|
||||
|
||||
== Name
|
||||
|
||||
cowboy_req:sock - Socket address and port
|
||||
|
||||
== Description
|
||||
|
||||
[source,erlang]
|
||||
----
|
||||
sock(Req :: cowboy_req:req()) -> Info
|
||||
|
||||
Info :: {inet:ip_address(), inet:port_number()}
|
||||
----
|
||||
|
||||
Return the socket's IP address and port number.
|
||||
|
||||
The socket information can also be obtained using pattern matching:
|
||||
|
||||
[source,erlang]
|
||||
----
|
||||
#{sock := {IP, Port}} = Req.
|
||||
----
|
||||
|
||||
== Arguments
|
||||
|
||||
Req::
|
||||
|
||||
The Req object.
|
||||
|
||||
== Return value
|
||||
|
||||
The socket's local IP address and port number.
|
||||
|
||||
== Changelog
|
||||
|
||||
* *2.0*: Function introduced.
|
||||
|
||||
== Examples
|
||||
|
||||
.Get the socket's IP address and port number.
|
||||
[source,erlang]
|
||||
----
|
||||
{IP, Port} = cowboy_req:sock(Req).
|
||||
----
|
||||
|
||||
== See also
|
||||
|
||||
link:man:cowboy_req(3)[cowboy_req(3)],
|
||||
link:man:cowboy_req:peer(3)[cowboy_req:peer(3)],
|
||||
link:man:cowboy_req:cert(3)[cowboy_req:cert(3)]
|
Loading…
Add table
Add a link
Reference in a new issue