diff options
author | Loïc Hoguin <[email protected]> | 2017-02-19 09:46:11 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2017-02-19 09:46:11 +0100 |
commit | 91ae70b06c9cc486ea2c2cf91b94de799ceb53b2 (patch) | |
tree | 37cc4d2dffbaef0e103c1f834e7ae7117ffd51ca /doc/src/manual/cowboy_req.set_resp_cookie.asciidoc | |
parent | 87a05a12199cc9f0a569669d96d6c65761e8ff97 (diff) | |
download | cowboy-91ae70b06c9cc486ea2c2cf91b94de799ceb53b2.tar.gz cowboy-91ae70b06c9cc486ea2c2cf91b94de799ceb53b2.tar.bz2 cowboy-91ae70b06c9cc486ea2c2cf91b94de799ceb53b2.zip |
Change the order of set_resp_cookie arguments
The Opts value is put last, to be more consistent with the
rest of the cowboy_req module.
Additionally a test handler was fixed which reduced the number
of errors in http_SUITE.
Diffstat (limited to 'doc/src/manual/cowboy_req.set_resp_cookie.asciidoc')
-rw-r--r-- | doc/src/manual/cowboy_req.set_resp_cookie.asciidoc | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/doc/src/manual/cowboy_req.set_resp_cookie.asciidoc b/doc/src/manual/cowboy_req.set_resp_cookie.asciidoc index f4643ff..2831059 100644 --- a/doc/src/manual/cowboy_req.set_resp_cookie.asciidoc +++ b/doc/src/manual/cowboy_req.set_resp_cookie.asciidoc @@ -11,7 +11,7 @@ cowboy_req:set_resp_cookie - Set a cookie set_resp_cookie(Name, Value, Req :: cowboy_req:req()) -> set_resp_cookie(Name, Value, [], Req) -set_resp_cookie(Name, Value, Opts, Req :: cowboy_req:req()) +set_resp_cookie(Name, Value, Req :: cowboy_req:req(), Opts) -> Req Name :: binary() %% case sensitive @@ -33,14 +33,14 @@ Value:: Cookie value. -Opts:: - -Optional cookie options. - Req:: The Req object. +Opts:: + +Cookie options. + == Return value A new Req object is returned. @@ -66,44 +66,38 @@ Req = cowboy_req:set_resp_cookie(<<"sessionid">>, SessionID, Req0). .Set a cookie with an expiration time [source,erlang] ---- -Req = cowboy_req:set_resp_cookie(<<"lang">>, <<"fr-FR">>, [ - {max_age, 3600} -], Req0). +Req = cowboy_req:set_resp_cookie(<<"lang">>, <<"fr-FR">>, + Req0, #{max_age => 3600}). ---- .Delete a cookie [source,erlang] ---- -Req = cowboy_req:set_resp_cookie(<<"sessionid">>, <<>>, [ - {max_age, 0} -], Req0). +Req = cowboy_req:set_resp_cookie(<<"sessionid">>, <<>>, + Req0, #{max_age => 0}). ---- .Set a cookie for a specific domain and path [source,erlang] ---- -Req = cowboy_req:set_resp_cookie(<<"inaccount">>, <<"1">>, [ - {domain, "my.example.org"}, - {path, "/account"} -], Req0). +Req = cowboy_req:set_resp_cookie(<<"inaccount">>, <<"1">>, + Req0, #{domain => "my.example.org", path => "/account"}). ---- .Restrict a cookie to HTTPS [source,erlang] ---- SessionID = base64:encode(crypto:strong_rand_bytes(32)), -Req = cowboy_req:set_resp_cookie(<<"sessionid">>, SessionID, [ - {secure, true} -], Req0). +Req = cowboy_req:set_resp_cookie(<<"sessionid">>, SessionID, + Req0, #{secure => true}). ---- .Restrict a cookie to HTTP [source,erlang] ---- SessionID = base64:encode(crypto:strong_rand_bytes(32)), -Req = cowboy_req:set_resp_cookie(<<"sessionid">>, SessionID, [ - {http_only, true} -], Req0). +Req = cowboy_req:set_resp_cookie(<<"sessionid">>, SessionID, + Req0, #{http_only => true}). ---- == See also |