aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_req.erl
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 /src/cowboy_req.erl
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 'src/cowboy_req.erl')
-rw-r--r--src/cowboy_req.erl10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/cowboy_req.erl b/src/cowboy_req.erl
index ca31105..ffc6e12 100644
--- a/src/cowboy_req.erl
+++ b/src/cowboy_req.erl
@@ -326,18 +326,18 @@ binding(Name, Req) ->
-spec binding(atom(), req(), Default) -> any() | Default when Default::any().
binding(Name, #{bindings := Bindings}, Default) when is_atom(Name) ->
- case lists:keyfind(Name, 1, Bindings) of
- {_, Value} -> Value;
- false -> Default
+ case Bindings of
+ #{Name := Value} -> Value;
+ _ -> Default
end;
binding(Name, _, Default) when is_atom(Name) ->
Default.
--spec bindings(req()) -> [{atom(), any()}].
+-spec bindings(req()) -> cowboy_router:bindings().
bindings(#{bindings := Bindings}) ->
Bindings;
bindings(_) ->
- [].
+ #{}.
-spec header(binary(), req()) -> binary() | undefined.
header(Name, Req) ->