Merge current v2.11 into v3.0

This commit is contained in:
mmatur 2024-03-12 10:38:29 +01:00
commit 05be441027
No known key found for this signature in database
GPG key ID: 2FFE42FC256CFF8E
156 changed files with 5826 additions and 8436 deletions

View file

@ -6,6 +6,7 @@ import (
"fmt"
"net/http"
"reflect"
"slices"
"strings"
"github.com/containous/alice"
@ -99,7 +100,7 @@ func checkRecursion(ctx context.Context, middlewareName string) (context.Context
if !ok {
currentStack = []string{}
}
if inSlice(middlewareName, currentStack) {
if slices.Contains(currentStack, middlewareName) {
return ctx, fmt.Errorf("could not instantiate middleware %s: recursion detected in %s", middlewareName, strings.Join(append(currentStack, middlewareName), "->"))
}
return context.WithValue(ctx, middlewareStackKey, append(currentStack, middlewareName)), nil
@ -392,12 +393,3 @@ func (b *Builder) buildConstructor(ctx context.Context, middlewareName string) (
// this would not enable tracing.
return observability.WrapMiddleware(ctx, middleware), nil
}
func inSlice(element string, stack []string) bool {
for _, value := range stack {
if value == element {
return true
}
}
return false
}