aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_req.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2012-09-15 22:51:37 +0200
committerLoïc Hoguin <[email protected]>2012-09-15 22:51:37 +0200
commit9ef94fb64e3bbec6b2cf7b31b96050c3c67a6438 (patch)
treec6fae91158eaae751a82b398e314e52a0a824fdf /src/cowboy_req.erl
parentf65f7d19a843fdc805ede8d2d3d5f28c449dbceb (diff)
downloadcowboy-9ef94fb64e3bbec6b2cf7b31b96050c3c67a6438.tar.gz
cowboy-9ef94fb64e3bbec6b2cf7b31b96050c3c67a6438.tar.bz2
cowboy-9ef94fb64e3bbec6b2cf7b31b96050c3c67a6438.zip
Introduce cowboy_req:set_meta/3 to set request metadata
Diffstat (limited to 'src/cowboy_req.erl')
-rw-r--r--src/cowboy_req.erl10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/cowboy_req.erl b/src/cowboy_req.erl
index ad6c1a4..2625c58 100644
--- a/src/cowboy_req.erl
+++ b/src/cowboy_req.erl
@@ -49,6 +49,7 @@
-export([cookies/1]).
-export([meta/2]).
-export([meta/3]).
+-export([set_meta/3]).
%% Request body API.
-export([has_body/1]).
@@ -429,6 +430,15 @@ meta(Name, Req, Default) ->
false -> {Default, Req}
end.
+%% @doc Set metadata information.
+%%
+%% You can use this function to attach information about the request.
+%%
+%% If the value already exists it will be overwritten.
+-spec set_meta(atom(), any(), Req) -> Req when Req::req().
+set_meta(Name, Value, Req=#http_req{meta=Meta}) ->
+ Req#http_req{meta=[{Name, Value}|lists:keydelete(Name, 1, Meta)]}.
+
%% Request Body API.
%% @doc Return whether the request message has a body.