1
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-16 21:56:40 -05:00

caddyhttp: Make route provisioning idempotent (#6558)

ref: https://github.com/caddyserver/caddy/issues/6551
This commit is contained in:
Jesper Brix Rosenkilde 2024-09-03 19:57:55 +02:00 committed by GitHub
parent c050a37e1c
commit 91e62db666
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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))