-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Add non regex pathPrefix #2592
Add non regex pathPrefix #2592
Conversation
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.
LGTM
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.
LGTM. That will be a huge improvement 👼
server/rules.go
Outdated
@@ -54,11 +54,25 @@ func (r *Rules) path(paths ...string) *mux.Route { | |||
func (r *Rules) pathPrefix(paths ...string) *mux.Route { | |||
router := r.route.route.Subrouter() | |||
for _, path := range paths { | |||
router.PathPrefix(strings.TrimSpace(path)) | |||
cleanPath := strings.TrimSpace(path) | |||
if strings.Contains(cleanPath, "{") { |
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.
Can we leave a note here why {
is important?
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.
Done 👍
b020fbb
to
e98673d
Compare
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.
LGTM.
Signed-off-by: Emile Vauge <emile@vauge.com>
e98673d
to
0a1578a
Compare
What does this PR do?
This PR adds non regex
PathPrefix
&PathPrefixStrip
support.When no
{
character is found in the given path, we now bypass thegorilla/mux
regex implementation to use our lightweight implementation instead.Motivation
Fixes #2376
More
Additional Notes
The leading & trailing slash behavior has been tested to be the same as before.