Header matching
Specify a set of headers which requests must match in entirety.
For example, if you specify a set of headers in a route table for service B, a request from service A in your mesh to service B must contain the entire set of headers 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:
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 Enterprise 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: Requests to the host that include the header named X-route-to-myapp
are routed to the myapp
destination.
Match header name and value: Requests to the host that include the header X-route-to-myapp: v1
are routed to the myapp
destination.
Match header name and regex-defined value: Requests to the host that include headers such as X-route-to-myapp: v1
or X-route-to-myapp: v3
are routed to the myapp
destination.
Match anything except header name and value: Requests to the host that do not include the header X-route-to-myapp: v1
are routed 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.