Query parameter matching

Specify a set of URL query parameters which requests must match in entirety. For example, if you specify a set of URL query parameters in a route table for service B, a request from service A in your mesh to service B must contain the entire set of URL query parameters in order for the request to be routed. For other methods of request matching, see Match incoming requests.

Configuration

In a RouteTable resource, add the following matchers section to your route:

...
  http:
  - matchers:
    - queryParameters:
      - name: <key_name>
        value: <key_value>
        regex: <true|false>
    ...
Field Description
name The name of a key that must be present in the requested path's query string.
value The value of the query parameter.
regex Whether the query parameter value is written as a regular expression. Defaults to false.

For more information, see the Gloo Mesh API docs for route tables and for request matching.

Examples

For example, consider the following route table.

apiVersion: networking.gloo.solo.io/v2
kind: RouteTable
metadata:
  name: query-parameters-match
  namespace: global
spec:
  hosts:
    - 'myapp.global.svc.cluster.local'
  http:
  - matchers:
    - queryParameters:
      - name: <key_name>
        value: <key_value>
        regex: <true|false>
    forwardTo:
      destinations:
      - ref:
          name: myapp
          namespace: global
          cluster: ${REMOTE_CLUSTER1}
        port:
          number: 8090
        kind: SERVICE

To achieve the following example request matches, you might use these combinations of queryParameters settings. Remember that requests must match all specified query parameters.

Match only query key name: Requests to the host that include the query key ?version are routed to the myapp destination.

    - queryParameters:
      - name: version

Match query key name and value: Requests to the host that include the query ?version=stage are routed to the myapp destination.

    - queryParameters:
      - name: version
        value: stage

Match query key name and regex-defined value: Requests to the host that include queries such as ?version=stagev3 or ?version=stagev1 are routed to the myapp destination.

    - queryParameters:
      - name: version
        value: stagev.*
        regex: true

Next steps

Check out the guides in Forward requests to a destination to further build your route tables based on the destination type, and apply the route tables to your ingress gateway.