From 192b196d3ff940a2aa93f2d4175060a2c86f2bcf Mon Sep 17 00:00:00 2001 From: Trong Huu Nguyen Date: Tue, 5 Nov 2024 08:48:46 +0100 Subject: [PATCH] refactor(config): inline samesite options --- pkg/config/cookie.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/pkg/config/cookie.go b/pkg/config/cookie.go index d9f0b25..0064595 100644 --- a/pkg/config/cookie.go +++ b/pkg/config/cookie.go @@ -29,18 +29,16 @@ func (s SameSite) ToHttp() http.SameSite { } func (s SameSite) Validate() error { - if slices.Contains(sameSiteAll(), s) { - return nil - } - return fmt.Errorf("%q must be one of %q (was %q)", CookieSameSite, sameSiteAll(), s) -} - -func sameSiteAll() []SameSite { - return []SameSite{ + all := []SameSite{ SameSiteLax, SameSiteNone, SameSiteStrict, } + + if slices.Contains(all, s) { + return nil + } + return fmt.Errorf("%q must be one of %q (was %q)", CookieSameSite, all, s) } const (