Query parameter matching

Specify a set of URL query parameters which requests must match in entirety. 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:
    - 'one.solo.io'
  virtualGateways:
    - name: ingress-gateway
      namespace: gloo-mesh
      cluster: ${REMOTE_CLUSTER1}
  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: The ingress gateway forwards all requests to one.solo.io that include the query key ?version to the myapp destination.

    - queryParameters:
      - name: version

Match query key name and value: The ingress gateway forwards all requests to one.solo.io that include the query ?version=stage to the myapp destination.

    - queryParameters:
      - name: version
        value: stage

Match query key name and regex-defined value: The ingress gateway forwards all requests to one.solo.io that include queries such as ?version=stagev3 or ?version=stagev1 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.