From d2a3f2cedd7c00d0933222aed9c06b3149aa4db4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 4 Apr 2018 13:13:37 +0200 Subject: Cowboy 2.3.0 --- docs/en/cowboy/2.0/guide/req/index.html | 62 +++++++++++++++++---------------- 1 file changed, 32 insertions(+), 30 deletions(-) (limited to 'docs/en/cowboy/2.0/guide/req/index.html') diff --git a/docs/en/cowboy/2.0/guide/req/index.html b/docs/en/cowboy/2.0/guide/req/index.html index 1b81cdfc..d6f7a2fd 100644 --- a/docs/en/cowboy/2.0/guide/req/index.html +++ b/docs/en/cowboy/2.0/guide/req/index.html @@ -7,7 +7,7 @@ - + Nine Nines: The Req object @@ -91,7 +91,7 @@ head. The following example sends a simple "Hello world!" response when the method is GET, and a 405 error otherwise.

-
@@ -146,14 +146,14 @@ where the crash occurred.

The request method can be retrieved directly:

-
#{method := Method} = Req.

Or using a function:

-
@@ -175,14 +175,14 @@ want to redirect HTTP/1.1 clients to use Websocket, while HTTP/2 clients keep using HTTP/2.

The HTTP version can be retrieved directly:

-
#{version := Version} = Req.

Or using a function:

-
@@ -198,7 +198,7 @@ atoms.

The scheme, host, port, path and query string components of the effective request URI can all be retrieved directly:

-
@@ -211,7 +211,7 @@ http://www.gnu.org/software/src-highlite --> } = Req.

Or using the related functions:

-
@@ -230,7 +230,7 @@ for requests on secure HTTP/1.1 or HTTP/2 connections.

the cowboy_req:uri/1,2 function. By default, an absolute URI is returned:

-
@@ -240,7 +240,7 @@ http://www.gnu.org/software/src-highlite --> or all of the components. Various URIs or URI formats can be generated this way, including the origin form:

-
@@ -248,7 +248,7 @@ http://www.gnu.org/software/src-highlite --> URI = cowboy_req:uri(Req, #{host => undefined}).

The protocol relative form:

-
@@ -256,14 +256,14 @@ http://www.gnu.org/software/src-highlite --> URI = cowboy_req:uri(Req, #{scheme => undefined}).

The absolute URI without a query string:

-
URI = cowboy_req:uri(Req, #{qs => undefined}).

A different host:

-
@@ -280,7 +280,7 @@ They are only available after the routing.

Cowboy provides functions to retrieve one or all bindings.

To retrieve a single value:

-
@@ -289,14 +289,14 @@ http://www.gnu.org/software/src-highlite --> undefined will be returned. A different default value can be provided:

-
Value = cowboy_req:binding(userid, Req, 42).

To retrieve everything that was bound:

-
@@ -306,14 +306,14 @@ http://www.gnu.org/software/src-highlite --> or path segments at once using the ... qualifier.

To retrieve the segments captured from the host name:

-
HostInfo = cowboy_req:host_info(Req).

And the path segments:

-
@@ -328,7 +328,7 @@ in the route.

Cowboy provides two functions to access query parameters. You can use the first to get the entire list of parameters.

-
@@ -351,7 +351,7 @@ only the parameters you are interested in, and at the same time do any post processing you require using constraints. This function returns a map.

-
@@ -361,7 +361,7 @@ snippet will crash when the id parameter is not an integer, or when the lang parameter is empty. At the same time, the value for id will be converted to an integer term:

-
@@ -370,7 +370,7 @@ http://www.gnu.org/software/src-highlite --> if the lang key is not found. It will not be used if the key is found but has an empty value.

-
@@ -390,7 +390,7 @@ ensure that only one value was passed through.

or parsed into a more meaningful representation.

The get the raw value:

-
@@ -401,21 +401,21 @@ regardless of the underlying protocol.

When the header is missing from the request, undefined will be returned. A different default can be provided:

-
HeaderVal = cowboy_req:header(<<"content-type">>, Req, <<"text/plain">>).

All headers can be retrieved at once, either directly:

-
#{headers := AllHeaders} = Req.

Or using a function:

-
@@ -424,7 +424,7 @@ http://www.gnu.org/software/src-highlite --> headers. There is no function to parse all headers at once.

To parse a specific header:

-
@@ -436,7 +436,7 @@ and default values can be found in the manual.

change the default value. Note that it should be the parsed value directly:

-
@@ -451,14 +451,14 @@ http://www.gnu.org/software/src-highlite --> retrieved either directly or using a function.

To retrieve the peer directly:

-
#{peer := {IP, Port}} = Req.

And using a function:

-
@@ -524,6 +524,8 @@ client itself. It may also be a proxy or a gateway.

+
  • 2.3
  • +
  • 2.2
  • 2.1
  • -- cgit v1.2.3