0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 12:20:24 +00:00

Newly documented cow_cookie:cookie_opts() is now a map

This commit is contained in:
Loïc Hoguin 2019-10-10 14:52:02 +02:00
parent d52e84bdd9
commit ecb39eea10
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764

View file

@ -98,10 +98,6 @@
%% Internal. %% Internal.
-export([response_headers/2]). -export([response_headers/2]).
%% @todo Get rid of this type, use cow_cookie directly.
-type cookie_opts() :: map().
-export_type([cookie_opts/0]).
-type read_body_opts() :: #{ -type read_body_opts() :: #{
length => non_neg_integer() | infinity, length => non_neg_integer() | infinity,
period => non_neg_integer(), period => non_neg_integer(),
@ -704,11 +700,10 @@ set_resp_cookie(Name, Value, Req) ->
%% %%
%% The cookie value cannot contain any of the following characters: %% The cookie value cannot contain any of the following characters:
%% ,; \t\r\n\013\014 %% ,; \t\r\n\013\014
%% @todo Fix the cookie_opts() type. -spec set_resp_cookie(binary(), iodata(), Req, cow_cookie:cookie_opts())
-spec set_resp_cookie(binary(), iodata(), Req, cookie_opts())
-> Req when Req::req(). -> Req when Req::req().
set_resp_cookie(Name, Value, Req, Opts) -> set_resp_cookie(Name, Value, Req, Opts) ->
Cookie = cow_cookie:setcookie(Name, Value, maps:to_list(Opts)), Cookie = cow_cookie:setcookie(Name, Value, Opts),
RespCookies = maps:get(resp_cookies, Req, #{}), RespCookies = maps:get(resp_cookies, Req, #{}),
Req#{resp_cookies => RespCookies#{Name => Cookie}}. Req#{resp_cookies => RespCookies#{Name => Cookie}}.