diff options
author | Loïc Hoguin <[email protected]> | 2017-02-19 16:51:16 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2017-02-19 16:51:16 +0100 |
commit | 9255cdf1d783ff5deff783ae13b0d003f484bb86 (patch) | |
tree | 352ae4164e8ebb1eac9d11448fd095b4231795e6 /src/cowboy_req.erl | |
parent | 91ae70b06c9cc486ea2c2cf91b94de799ceb53b2 (diff) | |
download | cowboy-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.erl | 10 |
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) -> |