Merge remote-tracking branch 'upstream/v2.2' into mrg-current-v2.2
This commit is contained in:
commit
73ca7ad0c1
156 changed files with 1768 additions and 892 deletions
|
@ -8,6 +8,6 @@ import (
|
|||
)
|
||||
|
||||
// getLogger creates a logger configured with the middleware fields.
|
||||
func getLogger(ctx context.Context, middleware string, middlewareType string) logrus.FieldLogger {
|
||||
func getLogger(ctx context.Context, middleware, middlewareType string) logrus.FieldLogger {
|
||||
return log.FromContext(ctx).WithField(log.MiddlewareName, middleware).WithField(log.MiddlewareType, middlewareType)
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ type Builder struct {
|
|||
}
|
||||
|
||||
// Build Builds the response modifier.
|
||||
// It returns nil if there is no modifier to apply.
|
||||
func (f *Builder) Build(ctx context.Context, names []string) func(*http.Response) error {
|
||||
var modifiers []func(*http.Response) error
|
||||
|
||||
|
@ -44,7 +45,10 @@ func (f *Builder) Build(ctx context.Context, names []string) func(*http.Response
|
|||
for _, name := range conf.Chain.Middlewares {
|
||||
qualifiedNames = append(qualifiedNames, provider.GetQualifiedName(chainCtx, name))
|
||||
}
|
||||
modifiers = append(modifiers, f.Build(ctx, qualifiedNames))
|
||||
|
||||
if rm := f.Build(ctx, qualifiedNames); rm != nil {
|
||||
modifiers = append(modifiers, rm)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,5 +64,5 @@ func (f *Builder) Build(ctx context.Context, names []string) func(*http.Response
|
|||
}
|
||||
}
|
||||
|
||||
return func(response *http.Response) error { return nil }
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -169,6 +169,21 @@ func TestBuilderBuild(t *testing.T) {
|
|||
},
|
||||
assertResponse: func(t *testing.T, resp *http.Response) {},
|
||||
},
|
||||
|
||||
{
|
||||
desc: "chain without headers",
|
||||
middlewares: []string{"chain"},
|
||||
buildResponse: stubResponse,
|
||||
conf: map[string]*dynamic.Middleware{
|
||||
"foo": {IPWhiteList: &dynamic.IPWhiteList{}},
|
||||
"chain": {
|
||||
Chain: &dynamic.Chain{
|
||||
Middlewares: []string{"foo"},
|
||||
},
|
||||
},
|
||||
},
|
||||
assertResponse: func(t *testing.T, resp *http.Response) {},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
|
@ -184,6 +199,9 @@ func TestBuilderBuild(t *testing.T) {
|
|||
builder := NewBuilder(rtConf.Middlewares)
|
||||
|
||||
rm := builder.Build(context.Background(), test.middlewares)
|
||||
if rm == nil {
|
||||
return
|
||||
}
|
||||
|
||||
resp := test.buildResponse(test.conf)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue