From e13a5a8d70a3684a791f9f71fb04d6f37a8f807d Mon Sep 17 00:00:00 2001 From: sharbov Date: Tue, 6 Mar 2018 12:23:05 +0200 Subject: [PATCH] Rename Matcher to Glob --- route/matcher.go | 2 +- route/matcher_test.go | 2 +- route/route.go | 4 ++-- route/table.go | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/route/matcher.go b/route/matcher.go index 9a490e048..3a7274c66 100644 --- a/route/matcher.go +++ b/route/matcher.go @@ -21,5 +21,5 @@ func prefixMatcher(uri string, r *Route) bool { // globMatcher matches path to the routes' path using gobwas/glob. func globMatcher(uri string, r *Route) bool { - return r.Matcher.Match(uri) + return r.Glob.Match(uri) } diff --git a/route/matcher_test.go b/route/matcher_test.go index cf56bbcc5..76d69b4d5 100644 --- a/route/matcher_test.go +++ b/route/matcher_test.go @@ -61,5 +61,5 @@ func TestGlobMatcher(t *testing.T) { } func getRoute(path string) *Route { - return &Route{Path: path, Matcher: glob.MustCompile(path)} + return &Route{Path: path, Glob: glob.MustCompile(path)} } diff --git a/route/route.go b/route/route.go index c0aa48fde..e872027f8 100644 --- a/route/route.go +++ b/route/route.go @@ -9,8 +9,8 @@ import ( "strconv" "strings" - "github.com/gobwas/glob" "github.com/fabiolb/fabio/metrics" + "github.com/gobwas/glob" ) // Route maps a path prefix to one or more target URLs. @@ -39,7 +39,7 @@ type Route struct { total uint64 // Matcher represents compiled pattern. - Matcher glob.Glob + Glob glob.Glob } func (r *Route) addTarget(service string, targetURL *url.URL, fixedWeight float64, tags []string, opts map[string]string) { diff --git a/route/table.go b/route/table.go index dffd3bdfe..c20d86398 100644 --- a/route/table.go +++ b/route/table.go @@ -13,8 +13,8 @@ import ( "sync/atomic" "github.com/fabiolb/fabio/metrics" - "github.com/ryanuber/go-glob" glob2 "github.com/gobwas/glob" + "github.com/ryanuber/go-glob" ) var errInvalidPrefix = errors.New("route: prefix must not be empty") @@ -154,7 +154,7 @@ func (t Table) addRoute(d *RouteDef) error { switch { // add new host case t[host] == nil: - r := &Route{Host: host, Path: path, Matcher: glob2.MustCompile(path)} + r := &Route{Host: host, Path: path, Glob: glob2.MustCompile(path)} r.addTarget(d.Service, targetURL, d.Weight, d.Tags, d.Opts) t[host] = Routes{r}