mirror of
https://github.com/caddyserver/caddy.git
synced 2025-04-23 05:07:50 +08:00
Keep AnyMatch signature the same for now
This commit is contained in:
parent
5c5f7c2877
commit
c8e38e4a33
@ -1124,7 +1124,7 @@ func (lb LoadBalancing) tryAgain(ctx caddy.Context, start time.Time, retries int
|
||||
return false
|
||||
}
|
||||
|
||||
match, err := lb.RetryMatch.AnyMatch(req)
|
||||
match, err := lb.RetryMatch.AnyMatchWithError(req)
|
||||
if err != nil {
|
||||
logger.Error("error matching request for retry", zap.Error(err))
|
||||
return false
|
||||
|
@ -254,7 +254,7 @@ func wrapRoute(route Route) Middleware {
|
||||
nextCopy := next
|
||||
|
||||
// route must match at least one of the matcher sets
|
||||
matches, err := route.MatcherSets.AnyMatch(req)
|
||||
matches, err := route.MatcherSets.AnyMatchWithError(req)
|
||||
if err != nil {
|
||||
// allow matchers the opportunity to short circuit
|
||||
// the request and trigger the error handling chain
|
||||
@ -397,11 +397,30 @@ type RawMatcherSets []caddy.ModuleMap
|
||||
// the sets.
|
||||
type MatcherSets []MatcherSet
|
||||
|
||||
// AnyMatch returns true if req matches any of the matcher sets
|
||||
// in ms or if there are no matchers, in which case the request
|
||||
// always matches. If any matcher returns an error, we cut short
|
||||
// and return the error.
|
||||
func (ms MatcherSets) AnyMatch(req *http.Request) (bool, error) {
|
||||
// AnyMatch returns true if req matches any of the
|
||||
// matcher sets in ms or if there are no matchers,
|
||||
// in which case the request always matches.
|
||||
//
|
||||
// Deprecated: Use AnyMatchWithError instead.
|
||||
func (ms MatcherSets) AnyMatch(req *http.Request) bool {
|
||||
for _, m := range ms {
|
||||
match, err := m.MatchWithError(req)
|
||||
if err != nil {
|
||||
SetVar(req.Context(), MatcherErrorVarKey, err)
|
||||
return false
|
||||
}
|
||||
if match {
|
||||
return match
|
||||
}
|
||||
}
|
||||
return len(ms) == 0
|
||||
}
|
||||
|
||||
// AnyMatchWithError returns true if req matches any of the
|
||||
// matcher sets in ms or if there are no matchers, in which
|
||||
// case the request always matches. If any matcher returns
|
||||
// an error, we cut short and return the error.
|
||||
func (ms MatcherSets) AnyMatchWithError(req *http.Request) (bool, error) {
|
||||
for _, m := range ms {
|
||||
match, err := m.MatchWithError(req)
|
||||
if err != nil || match {
|
||||
|
Loading…
x
Reference in New Issue
Block a user