-
Notifications
You must be signed in to change notification settings - Fork 617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added new case insensitive matcher #553
Conversation
route/matcher.go
Outdated
@@ -12,6 +12,7 @@ type matcher func(uri string, r *Route) bool | |||
var Matcher = map[string]matcher{ | |||
"prefix": prefixMatcher, | |||
"glob": globMatcher, | |||
"noCase": noCaseMatcher, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this might be a terrible name, but it's the best I could come up with this evening. I'm open to suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe nocase
I've never done GoLang before, but this seemed pretty straight forward based on the other examples. Let me know if I missed anything. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks simple enough. Lets drop the camel case and call it nocase
. Also, please add a test in config/load_test.go
, update fabio.properties
and the documentation.
route/matcher.go
Outdated
@@ -12,6 +12,7 @@ type matcher func(uri string, r *Route) bool | |||
var Matcher = map[string]matcher{ | |||
"prefix": prefixMatcher, | |||
"glob": globMatcher, | |||
"noCase": noCaseMatcher, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe nocase
route/matcher.go
Outdated
func noCaseMatcher(uri string, r *Route) bool { | ||
lowerURI := strings.ToLower(uri) | ||
lowerPath := strings.ToLower(r.Path) | ||
return strings.HasPrefix(lowerURI, lowerPath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After looking at this again, I think this should be a case insensitive prefix match. Originally I was using EqualFold
. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// todo(fs): if this turns out to be a performance issue we should cache
// todo(fs): strings.ToLower(r.Path) in r.PathLower
return strings.HasPrefix(strings.ToLower(uri), strings.ToLower(r.Path))
config/load.go
Outdated
@@ -247,7 +247,7 @@ func load(cmdline, environ, envprefix []string, props *properties.Properties) (c | |||
return nil, fmt.Errorf("invalid proxy.strategy: %s", cfg.Proxy.Strategy) | |||
} | |||
|
|||
if cfg.Proxy.Matcher != "prefix" && cfg.Proxy.Matcher != "glob" && cfg.Proxy.Matcher != "noCase" { | |||
if cfg.Proxy.Matcher != "prefix" && cfg.Proxy.Matcher != "glob" && cfg.Proxy.Matcher != "nocase" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With respect to the case-insensitive prefix matching I think iprefix
is a better name.
fabio.properties
Outdated
@@ -297,6 +297,7 @@ | |||
# | |||
# prefix: prefix matching | |||
# glob: glob matching | |||
# nocase: matches using a case insensitive test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# iprefix: case-insensitive prefix matching
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some more comments.
I believe I've addressed all of your comments. I just wanted to make sure there wasn't something I missed that you're still waiting on. Are there any other changes you'd like to see on this? |
Any update on this? We really need this in order to migrate to fabio |
Thank you and sorry that it took so long! |
This adds the ability to have case insensitive matching for routes. This is important for projects that need to migrate from other load balancers that are case insensitive.