Skip to content
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

Merged
merged 1 commit into from
Dec 19, 2017
Merged

Conversation

emilevauge
Copy link
Member

@emilevauge emilevauge commented Dec 19, 2017

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 the gorilla/mux regex implementation to use our lightweight implementation instead.

Motivation

Fixes #2376

More

  • Added/updated tests

Additional Notes

The leading & trailing slash behavior has been tested to be the same as before.

Copy link
Contributor

@ldez ldez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@SantoDE SantoDE left a 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, "{") {
Copy link
Contributor

@timoreimann timoreimann Dec 19, 2017

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍

Copy link
Contributor

@timoreimann timoreimann left a 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>
@traefiker traefiker merged commit b23b261 into traefik:v1.5 Dec 19, 2017
@emilevauge emilevauge deleted the add-non-regex-pathprefix branch December 19, 2017 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants