aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_req.erl
diff options
context:
space:
mode:
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.