MCPcopy
hub / github.com/caddyserver/caddy / FromInterface

Method FromInterface

modules/caddyhttp/routes.go:441–458  ·  view source on GitHub ↗

FromInterface fills ms from an 'any' value obtained from LoadModule.

(matcherSets any)

Source from the content-addressed store, hash-verified

439
440// FromInterface fills ms from an 'any' value obtained from LoadModule.
441func (ms *MatcherSets) FromInterface(matcherSets any) error {
442 for _, matcherSetIfaces := range matcherSets.([]map[string]any) {
443 var matcherSet MatcherSet
444 for _, matcher := range matcherSetIfaces {
445 if m, ok := matcher.(RequestMatcherWithError); ok {
446 matcherSet = append(matcherSet, m)
447 continue
448 }
449 if m, ok := matcher.(RequestMatcher); ok {
450 matcherSet = append(matcherSet, m)
451 continue
452 }
453 return fmt.Errorf("decoded module is not a RequestMatcher or RequestMatcherWithError: %#v", matcher)
454 }
455 *ms = append(*ms, matcherSet)
456 }
457 return nil
458}
459
460// TODO: Is this used?
461func (ms MatcherSets) String() string {

Callers 2

ProvisionMatchersMethod · 0.80
ProvisionMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected