diff --git a/pkg/server/middleware/middlewares.go b/pkg/server/middleware/middlewares.go index e13bee412..65568049e 100644 --- a/pkg/server/middleware/middlewares.go +++ b/pkg/server/middleware/middlewares.go @@ -142,9 +142,9 @@ func (b *Builder) buildConstructor(ctx context.Context, middlewareName string) ( return nil, badConf } - qualifiedNames := make([]string, len(config.Chain.Middlewares)) - for i, name := range config.Chain.Middlewares { - qualifiedNames[i] = internal.GetQualifiedName(ctx, name) + var qualifiedNames []string + for _, name := range config.Chain.Middlewares { + qualifiedNames = append(qualifiedNames, internal.GetQualifiedName(ctx, name)) } config.Chain.Middlewares = qualifiedNames middleware = func(next http.Handler) (http.Handler, error) { diff --git a/pkg/server/router/router.go b/pkg/server/router/router.go index c27d42229..f75a75e49 100644 --- a/pkg/server/router/router.go +++ b/pkg/server/router/router.go @@ -143,9 +143,9 @@ func (m *Manager) buildRouterHandler(ctx context.Context, routerName string, rou } func (m *Manager) buildHTTPHandler(ctx context.Context, router *runtime.RouterInfo, routerName string) (http.Handler, error) { - qualifiedNames := make([]string, len(router.Middlewares)) - for i, name := range router.Middlewares { - qualifiedNames[i] = internal.GetQualifiedName(ctx, name) + var qualifiedNames []string + for _, name := range router.Middlewares { + qualifiedNames = append(qualifiedNames, internal.GetQualifiedName(ctx, name)) } router.Middlewares = qualifiedNames rm := m.modifierBuilder.Build(ctx, qualifiedNames)