httpcaddyfile: Fix sorting of repeated directives

Fixes #5037
This commit is contained in:
Matthew Holt
2022-09-13 13:43:21 -06:00
parent 20d487be57
commit 754fe4f7b4
4 changed files with 49 additions and 20 deletions
+22
View File
@@ -109,6 +109,17 @@ func (r Route) Empty() bool {
r.Group == ""
}
func (r Route) String() string {
handlersRaw := "["
for _, hr := range r.HandlersRaw {
handlersRaw += " " + string(hr)
}
handlersRaw += "]"
return fmt.Sprintf(`{Group:"%s" MatcherSetsRaw:%s HandlersRaw:%s Terminal:%t}`,
r.Group, r.MatcherSetsRaw, handlersRaw, r.Terminal)
}
// RouteList is a list of server routes that can
// create a middleware chain.
type RouteList []Route
@@ -331,4 +342,15 @@ func (ms *MatcherSets) FromInterface(matcherSets any) error {
return nil
}
// TODO: Is this used?
func (ms MatcherSets) String() string {
result := "["
for _, matcherSet := range ms {
for _, matcher := range matcherSet {
result += fmt.Sprintf(" %#v", matcher)
}
}
return result + " ]"
}
var routeGroupCtxKey = caddy.CtxKey("route_group")