aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_http_req.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2011-12-07 11:54:57 +0100
committerLoïc Hoguin <[email protected]>2011-12-07 11:54:57 +0100
commitce92ab1e633408b0d6b2d4bb4ba61d965208ef3c (patch)
treea41bcfb2daca5cfbf35840da216a5029ba99b381 /src/cowboy_http_req.erl
parenta12a910341dd22bd27096b50edf3d9820bc90384 (diff)
downloadcowboy-ce92ab1e633408b0d6b2d4bb4ba61d965208ef3c.tar.gz
cowboy-ce92ab1e633408b0d6b2d4bb4ba61d965208ef3c.tar.bz2
cowboy-ce92ab1e633408b0d6b2d4bb4ba61d965208ef3c.zip
Add cowboy_http_req:set_resp_cookie/4
Pretty much just an alias for a combination of set_resp_header and cookie.
Diffstat (limited to 'src/cowboy_http_req.erl')
-rw-r--r--src/cowboy_http_req.erl9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/cowboy_http_req.erl b/src/cowboy_http_req.erl
index d5ee3fa..e4cb33e 100644
--- a/src/cowboy_http_req.erl
+++ b/src/cowboy_http_req.erl
@@ -37,7 +37,7 @@
]). %% Request Body API.
-export([
- set_resp_header/3, set_resp_body/2,
+ set_resp_cookie/4, set_resp_header/3, set_resp_body/2,
has_resp_header/2, has_resp_body/1,
reply/2, reply/3, reply/4,
chunked_reply/2, chunked_reply/3, chunk/2,
@@ -361,6 +361,13 @@ body_qs(Req) ->
%% Response API.
+%% @doc Add a cookie header to the response.
+-spec set_resp_cookie(binary(), binary(), [cowboy_cookies:cookie_option()],
+ #http_req{}) -> {ok, #http_req{}}.
+set_resp_cookie(Name, Value, Options, Req) ->
+ {HeaderName, HeaderValue} = cowboy_cookies:cookie(Name, Value, Options),
+ set_resp_header(HeaderName, HeaderValue, Req).
+
%% @doc Add a header to the response.
-spec set_resp_header(http_header(), iodata(), #http_req{})
-> {ok, #http_req{}}.