aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-02-19 16:51:16 +0100
committerLoïc Hoguin <[email protected]>2017-02-19 16:51:16 +0100
commit9255cdf1d783ff5deff783ae13b0d003f484bb86 (patch)
tree352ae4164e8ebb1eac9d11448fd095b4231795e6 /doc
parent91ae70b06c9cc486ea2c2cf91b94de799ceb53b2 (diff)
downloadcowboy-9255cdf1d783ff5deff783ae13b0d003f484bb86.tar.gz
cowboy-9255cdf1d783ff5deff783ae13b0d003f484bb86.tar.bz2
cowboy-9255cdf1d783ff5deff783ae13b0d003f484bb86.zip
Change the type of bindings from a list to a map
Maps make more sense because the keys are unique.
Diffstat (limited to 'doc')
-rw-r--r--doc/src/guide/req.asciidoc7
-rw-r--r--doc/src/manual/cowboy_req.bindings.asciidoc6
-rw-r--r--doc/src/manual/cowboy_router.asciidoc2
3 files changed, 5 insertions, 10 deletions
diff --git a/doc/src/guide/req.asciidoc b/doc/src/guide/req.asciidoc
index 9afee09..b879fa3 100644
--- a/doc/src/guide/req.asciidoc
+++ b/doc/src/guide/req.asciidoc
@@ -197,8 +197,6 @@ And any other combination.
=== Bindings
-// @todo Bindings should probably be a map themselves.
-
Bindings are the host and path components that you chose
to extract when defining the routes of your application.
They are only available after the routing.
@@ -222,10 +220,7 @@ To retrieve everything that was bound:
[source,erlang]
Bindings = cowboy_req:bindings(Req).
-They are returned as a list of key/value pairs, with
-keys being atoms.
-
-// ...
+They are returned as a map, with keys being atoms.
The Cowboy router also allows you to capture many host
or path segments at once using the `...` qualifier.
diff --git a/doc/src/manual/cowboy_req.bindings.asciidoc b/doc/src/manual/cowboy_req.bindings.asciidoc
index 3099366..b399e95 100644
--- a/doc/src/manual/cowboy_req.bindings.asciidoc
+++ b/doc/src/manual/cowboy_req.bindings.asciidoc
@@ -8,10 +8,10 @@ cowboy_req:bindings - Access all values bound from the route
[source,erlang]
----
-bindings(Req :: cowboy_req:req()) -> [{Name :: atom(), any()}]
+bindings(Req :: cowboy_req:req()) -> cowboy_router:bindings()
----
-Return all bindings as a list of key/value pairs.
+Return a map containing all bindings.
== Arguments
@@ -27,7 +27,7 @@ automatically converting numbers to integer).
== Changelog
-* *2.0*: Only the values are returned, it is no longer wrapped in a tuple.
+* *2.0*: Only the values are returned, they are no longer wrapped in a tuple.
* *1.0*: Function introduced.
== Examples
diff --git a/doc/src/manual/cowboy_router.asciidoc b/doc/src/manual/cowboy_router.asciidoc
index a830618..61b8d57 100644
--- a/doc/src/manual/cowboy_router.asciidoc
+++ b/doc/src/manual/cowboy_router.asciidoc
@@ -33,7 +33,7 @@ a 404 response otherwise.
[source,erlang]
----
-bindings() :: [{atom(), binary()}]
+bindings() :: #{atom() => any()}
----
Bindings found during routing.