From e37af7ac0caffc661def1593c55b212cc2f05d3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sun, 15 Mar 2020 18:41:48 +0100 Subject: Document the cookie store option and related modules Also contains a few small changes and Dialyzer fixes. --- src/gun_cookies_list.erl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/gun_cookies_list.erl') diff --git a/src/gun_cookies_list.erl b/src/gun_cookies_list.erl index e8cf17a..77cc236 100644 --- a/src/gun_cookies_list.erl +++ b/src/gun_cookies_list.erl @@ -15,12 +15,13 @@ %% A reference cookie store implemented as a list of cookies. %% This cookie store cannot be shared between connections. -module(gun_cookies_list). +-behavior(gun_cookies). -export([init/0]). -export([init/1]). -export([query/2]). -export([set_cookie_secure_match/2]). --export([set_cookie_take_exact_match/2]). +-export([set_cookie_get_exact_match/2]). -export([store/2]). -export([gc/1]). -export([session_gc/1]). @@ -33,6 +34,7 @@ -type opts() :: #{ }. +-export_type([opts/0]). -spec init() -> {?MODULE, state()}. init() -> @@ -43,7 +45,7 @@ init(_Opts) -> {?MODULE, #{cookies => []}}. -spec query(State, uri_string:uri_map()) - -> {ok, [{binary(), binary()}], State} + -> {ok, [gun_cookies:cookie()], State} when State::state(). query(State=#{cookies := Cookies}, URI) -> CurrentTime = erlang:universaltime(), @@ -100,13 +102,13 @@ set_cookie_secure_match(#{cookies := Cookies}, _ -> match end. --spec set_cookie_take_exact_match(State, #{ +-spec set_cookie_get_exact_match(State, #{ name := binary(), domain := binary(), host_only := boolean(), path := binary() }) -> {ok, gun_cookies:cookie(), State} | error when State::state(). -set_cookie_take_exact_match(State=#{cookies := Cookies0}, Match) -> +set_cookie_get_exact_match(State=#{cookies := Cookies0}, Match) -> Result = [Cookie || Cookie <- Cookies0, Match =:= maps:with([name, domain, host_only, path], Cookie)], Cookies = [Cookie || Cookie <- Cookies0, -- cgit v1.2.3