1
0
Fork 0

Support domain configuration for sticky cookies

This commit is contained in:
Jorge 2025-03-06 09:38:04 +01:00 committed by GitHub
parent fa76ed57d3
commit 740b4cfd25
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 184 additions and 0 deletions

View file

@ -30,6 +30,7 @@ type stickyCookie struct {
sameSite string
maxAge int
path string
domain string
}
func convertSameSite(sameSite string) http.SameSite {
@ -87,6 +88,7 @@ func New(sticky *dynamic.Sticky, wantHealthCheck bool) *Balancer {
sameSite: sticky.Cookie.SameSite,
maxAge: sticky.Cookie.MaxAge,
path: "/",
domain: sticky.Cookie.Domain,
}
if sticky.Cookie.Path != nil {
balancer.stickyCookie.path = *sticky.Cookie.Path
@ -281,6 +283,7 @@ func (b *Balancer) writeStickyCookie(w http.ResponseWriter, handler *namedHandle
Secure: b.stickyCookie.secure,
SameSite: convertSameSite(b.stickyCookie.sameSite),
MaxAge: b.stickyCookie.maxAge,
Domain: b.stickyCookie.domain,
}
http.SetCookie(w, cookie)
}