Files
styx/proxy/match/match.go
2025-09-26 08:49:53 +02:00

46 lines
680 B
Go

package match
import (
"fmt"
"net"
"net/http"
)
type Matchers map[string]map[string]Matcher
func (all Matchers) Get(kind, name string) (m Matcher, err error) {
if typeMatchers, ok := all[kind]; ok {
if m, ok = typeMatchers[name]; ok {
return
}
return nil, fmt.Errorf("no %s matcher named %q found", kind, name)
}
return nil, fmt.Errorf("no %s matcher found", kind)
}
type Matcher interface {
Name() string
}
type Updater interface {
Update() error
}
type IP interface {
Matcher
MatchesIP(net.IP) bool
}
type Request interface {
Matcher
MatchesRequest(*http.Request) bool
}
type Response interface {
Matcher
MatchesResponse(*http.Response) bool
}