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 support for Query String filtering #1934

Merged
merged 2 commits into from Aug 24, 2017
Merged

Conversation

driverpt
Copy link
Contributor

@driverpt driverpt commented Aug 9, 2017

As title says

Usage:

Query: foo=bar, bar=baz

Copy link
Member

@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

@driverpt
Copy link
Contributor Author

:shipit: !!!!

@ldez
Copy link
Member

ldez commented Aug 17, 2017

https://github.com/containous/traefik/blob/master/.github/MAINTAINER.md#pr-review-process

Copy link
Contributor

@nmengin nmengin left a comment

Choose a reason for hiding this comment

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

Many thanks for this PR 👏

LGTM

@@ -109,6 +109,7 @@ Following is the list of existing matcher rules along with examples:
- `PathPrefix: /products/, /articles/{category}/{id:[0-9]+}`: Match request prefix path. It accepts a sequence of literal and regular expression prefix paths.
- `PathPrefixStrip: /products/`: Match request prefix path and strip off the path prefix prior to forwarding the request to the backend. It accepts a sequence of literal prefix paths. Starting with Traefik 1.3, the stripped prefix path will be available in the `X-Forwarded-Prefix` header.
- `PathPrefixStripRegex: /articles/{category}/{id:[0-9]+}`: Match request prefix path and strip off the path prefix prior to forwarding the request to the backend. It accepts a sequence of literal and regular expression prefix paths. Starting with Traefik 1.3, the stripped prefix path will be available in the `X-Forwarded-Prefix` header.
- `Query: foo=bar, bar=baz`: Match Query String parameters. It accepts a sequence of key=value pairs.
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For now it doesn't. Currently it splits the = sign and analyzes each part. I can do a PR in the future supporting Regex but i need to figure out how.

Copy link

@ztl8702 ztl8702 Jan 24, 2018

Choose a reason for hiding this comment

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

Actually, it does.
I just tested: Query: a={a:[0-1]+} will match http://foobar/?a=1 but not http://foobar/?a=2 for example. Exactly as Juliens pointed out: such Regex syntax is implemented in the underlying mux package, by just splitting the = sign driverpt's commit actually "unintentionally" enables this feature. (But I am saying this is a good thing. It worked for my use case. ) https://github.com/containous/mux/blob/06ccd3e75091eb659b1d720cda0e16bc7057954c/route.go#L387

Should update the docs I guess?

Copy link
Member

@emilevauge emilevauge left a comment

Choose a reason for hiding this comment

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

Thanks @driverpt
LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants