From 91e62db666b799ba4bb6577d8548fbe779d91c28 Mon Sep 17 00:00:00 2001 From: Jesper Brix Rosenkilde Date: Tue, 3 Sep 2024 19:57:55 +0200 Subject: [PATCH] caddyhttp: Make route provisioning idempotent (#6558) ref: https://github.com/caddyserver/caddy/issues/6551 --- modules/caddyhttp/routes.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/caddyhttp/routes.go b/modules/caddyhttp/routes.go index 6f237149..54a3f38e 100644 --- a/modules/caddyhttp/routes.go +++ b/modules/caddyhttp/routes.go @@ -159,6 +159,9 @@ func (r *Route) ProvisionHandlers(ctx caddy.Context, metrics *Metrics) error { r.Handlers = append(r.Handlers, handler.(MiddlewareHandler)) } + // Make ProvisionHandlers idempotent by clearing the middleware field + r.middleware = []Middleware{} + // pre-compile the middleware handler chain for _, midhandler := range r.Handlers { r.middleware = append(r.middleware, wrapMiddleware(ctx, midhandler, metrics))