From 9ef94fb64e3bbec6b2cf7b31b96050c3c67a6438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sat, 15 Sep 2012 22:51:37 +0200 Subject: Introduce cowboy_req:set_meta/3 to set request metadata --- src/cowboy_req.erl | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/cowboy_req.erl') 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. -- cgit v1.2.3