Send 'Retry-After' to comply with RFC6585.
This commit is contained in:
parent
027093a5a5
commit
8d75aba7eb
29 changed files with 435 additions and 172 deletions
9
vendor/github.com/vulcand/oxy/roundrobin/stickysessions.go
generated
vendored
9
vendor/github.com/vulcand/oxy/roundrobin/stickysessions.go
generated
vendored
|
@ -1,4 +1,3 @@
|
|||
// package stickysession is a mixin for load balancers that implements layer 7 (http cookie) session affinity
|
||||
package roundrobin
|
||||
|
||||
import (
|
||||
|
@ -6,12 +5,14 @@ import (
|
|||
"net/url"
|
||||
)
|
||||
|
||||
// StickySession is a mixin for load balancers that implements layer 7 (http cookie) session affinity
|
||||
type StickySession struct {
|
||||
cookieName string
|
||||
}
|
||||
|
||||
// NewStickySession creates a new StickySession
|
||||
func NewStickySession(cookieName string) *StickySession {
|
||||
return &StickySession{cookieName}
|
||||
return &StickySession{cookieName: cookieName}
|
||||
}
|
||||
|
||||
// GetBackend returns the backend URL stored in the sticky cookie, iff the backend is still in the valid list of servers.
|
||||
|
@ -32,11 +33,11 @@ func (s *StickySession) GetBackend(req *http.Request, servers []*url.URL) (*url.
|
|||
|
||||
if s.isBackendAlive(serverURL, servers) {
|
||||
return serverURL, true, nil
|
||||
} else {
|
||||
return nil, false, nil
|
||||
}
|
||||
return nil, false, nil
|
||||
}
|
||||
|
||||
// StickBackend creates and sets the cookie
|
||||
func (s *StickySession) StickBackend(backend *url.URL, w *http.ResponseWriter) {
|
||||
cookie := &http.Cookie{Name: s.cookieName, Value: backend.String(), Path: "/"}
|
||||
http.SetCookie(*w, cookie)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue