Files
isp-gate-service/service/matcher/runtime_matcher.go
T
2019-11-08 16:36:43 +03:00

25 lines
496 B
Go

package matcher
import (
"strings"
)
type runtimeMatcher struct {
patterns []string
}
func (mm runtimeMatcher) Match(method string) []string {
resp := make([]string, 0)
for _, pattern := range mm.patterns {
patternLen := len(pattern)
if patternLen > 0 && pattern[patternLen-1] == '*' {
if strings.HasPrefix(method, pattern[:patternLen-1]) {
resp = append(resp, pattern)
}
} else if strings.EqualFold(method, pattern) {
resp = append(resp, pattern)
}
}
return resp
}