-
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 support for Query String filtering #1934
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.
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. |
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.
It accepts some regexp too ?
http://www.gorillatoolkit.org/pkg/mux#Route.Queries
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.
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.
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.
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?
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.
Thanks @driverpt
LGTM
As title says
Usage: