| 1 |
= cowboy_req:host(3) |
| 2 |
|
| 3 |
== Name |
| 4 |
|
| 5 |
cowboy_req:host - URI host name |
| 6 |
|
| 7 |
== Description |
| 8 |
|
| 9 |
[source,erlang] |
| 10 |
---- |
| 11 |
host(Req :: cowboy_req:req()) -> Host :: binary() |
| 12 |
---- |
| 13 |
|
| 14 |
Return the host name of the effective request URI. |
| 15 |
|
| 16 |
The host name can also be obtained using pattern matching: |
| 17 |
|
| 18 |
[source,erlang] |
| 19 |
---- |
| 20 |
#{host := Host} = Req. |
| 21 |
---- |
| 22 |
|
| 23 |
== Arguments |
| 24 |
|
| 25 |
Req:: |
| 26 |
|
| 27 |
The Req object. |
| 28 |
|
| 29 |
== Return value |
| 30 |
|
| 31 |
The host name is returned as a lowercase binary string. |
| 32 |
It is case insensitive. |
| 33 |
|
| 34 |
== Changelog |
| 35 |
|
| 36 |
* *2.0*: Only the host name is returned, it is no longer wrapped in a tuple. |
| 37 |
* *1.0*: Function introduced. |
| 38 |
|
| 39 |
== Examples |
| 40 |
|
| 41 |
.Get the effective request URI's host name |
| 42 |
[source,erlang] |
| 43 |
---- |
| 44 |
Host = cowboy_req:host(Req). |
| 45 |
---- |
| 46 |
|
| 47 |
== See also |
| 48 |
|
| 49 |
link:man:cowboy_req(3)[cowboy_req(3)], |
| 50 |
link:man:cowboy_req:binding(3)[cowboy_req:binding(3)], |
| 51 |
link:man:cowboy_req:bindings(3)[cowboy_req:bindings(3)], |
| 52 |
link:man:cowboy_req:host_info(3)[cowboy_req:host_info(3)] |