Add support for Query String filtering
This commit is contained in:
parent
8105f1c379
commit
0d56a98836
2 changed files with 11 additions and 0 deletions
|
@ -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.
|
- `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.
|
- `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.
|
- `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.
|
||||||
|
|
||||||
In order to use regular expressions with Host and Path matchers, you must declare an arbitrarily named variable followed by the colon-separated regular expression, all enclosed in curly braces. Any pattern supported by [Go's regexp package](https://golang.org/pkg/regexp/) may be used. Example: `/posts/{id:[0-9]+}`.
|
In order to use regular expressions with Host and Path matchers, you must declare an arbitrarily named variable followed by the colon-separated regular expression, all enclosed in curly braces. Any pattern supported by [Go's regexp package](https://golang.org/pkg/regexp/) may be used. Example: `/posts/{id:[0-9]+}`.
|
||||||
|
|
||||||
|
|
|
@ -131,6 +131,15 @@ func (r *Rules) headersRegexp(headers ...string) *mux.Route {
|
||||||
return r.route.route.HeadersRegexp(headers...)
|
return r.route.route.HeadersRegexp(headers...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *Rules) query(query ...string) *mux.Route {
|
||||||
|
var queries []string
|
||||||
|
for _, elem := range query {
|
||||||
|
queries = append(queries, strings.Split(elem, "=")...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return r.route.route.Queries(queries...)
|
||||||
|
}
|
||||||
|
|
||||||
func (r *Rules) parseRules(expression string, onRule func(functionName string, function interface{}, arguments []string) error) error {
|
func (r *Rules) parseRules(expression string, onRule func(functionName string, function interface{}, arguments []string) error) error {
|
||||||
functions := map[string]interface{}{
|
functions := map[string]interface{}{
|
||||||
"Host": r.host,
|
"Host": r.host,
|
||||||
|
@ -146,6 +155,7 @@ func (r *Rules) parseRules(expression string, onRule func(functionName string, f
|
||||||
"HeadersRegexp": r.headersRegexp,
|
"HeadersRegexp": r.headersRegexp,
|
||||||
"AddPrefix": r.addPrefix,
|
"AddPrefix": r.addPrefix,
|
||||||
"ReplacePath": r.replacePath,
|
"ReplacePath": r.replacePath,
|
||||||
|
"Query": r.query,
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(expression) == 0 {
|
if len(expression) == 0 {
|
||||||
|
|
Loading…
Add table
Reference in a new issue