Header matching
Specify a set of headers 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:
Field | Description |
---|---|
name | The name of the header in the request. |
value | The value of the header. If you omit this value, requests that have the header name match regardless of the header’s value. |
regex | Whether the header value is written as a regular expression. Defaults to false. |
invertMatch | If set to true, the result of the match is inverted, or only match if the string is not found. Defaults to false. |
For more information, see the Gloo Mesh Gateway API docs for route tables and for request matching.
Examples
For example, consider the following route table.
To achieve the following example request matches, you might use these combinations of headers
settings. Remember that requests must match all specified headers.
Match only header name: The ingress gateway forwards all requests to one.solo.io
that include the header named X-route-to-myapp
to the myapp
destination.
Match header name and value: The ingress gateway forwards all requests to one.solo.io
that include the header X-route-to-myapp: v1
to the myapp
destination.
Match header name and regex-defined value: The ingress gateway forwards all requests to one.solo.io
that include headers such as X-route-to-myapp: v1
or X-route-to-myapp: v3
to the myapp
destination.
Match anything except header name and value: The ingress gateway forwards all requests to one.solo.io
that do not include the header X-route-to-myapp: v1
to the myapp
destination. Note that requests including headers such as X-route-to-myapp: v2
are matched and forwarded.
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.