refactor(middleware): clone middleware definitions before modification

- This change enhances the integrity of middleware configurations by ensuring original definitions remain unchanged.
This commit is contained in:
yusing
2026-02-15 20:03:43 +08:00
parent cc516d23db
commit af62ac98d3

View File

@@ -3,6 +3,7 @@ package middleware
import (
"errors"
"fmt"
"maps"
"os"
"path"
"sort"
@@ -92,6 +93,7 @@ func BuildMiddlewareFromChainRaw(name string, defs []map[string]any) (*Middlewar
chainErr.AddSubjectf(err, "%s[%d]", name, i)
continue
}
def = maps.Clone(def)
delete(def, "use")
m, err := base.New(def)
if err != nil {