Add case insensitive param on service route match
This commit adds in a new feature that allows service routers to specify that
paths and path prefixes should ignore upper / lower casing when matching URLs.
Co-authored-by: Derek Menteer <105233703+hashi-derek@users.noreply.github.com>
@ -456,6 +457,15 @@ Specifies the path prefix to match on the HTTP request path. When using this fie
- Default: None
- Data type: String
### `Routes[].Match{}.HTTP{}.CaseInsensitive`
Specifies the path prefix to match on the HTTP request path must be case insensitive or not.
#### Values
- Default: `false`
- Data type: Boolean
### `Routes[].Match{}.HTTP{}.PathRegex`
Specifies a regular expression to match on the HTTP request path. When using this field, do not configure `PathExact` or `PathPrefix` in the same HTTP map. The syntax for the regular expression field is proxy-specific. When [using Envoy](/consul/docs/connect/proxies/envoy), refer to [the documentation for Envoy v1.11.2 or newer](https://github.com/google/re2/wiki/Syntax) or [the documentation for Envoy v1.11.1 or older](https://en.cppreference.com/w/cpp/regex/ecmascript), depending on the version of Envoy you use.
@ -1372,6 +1382,78 @@ spec:
</Tab>
</Tabs>
### Path prefix matching with case insensitive
The following example routes HTTP requests for the `web` service to a service named `admin` when they have `/admin` or `/Admin` at the start of their path.
<Tabs>
<Tab heading="HCL" group="hcl">
```hcl
Kind = "service-router"
Name = "web"
Routes = [
{
Match {
HTTP {
PathPrefix = "/Admin"
CaseInsensitive = true
}
}
Destination {
Service = "admin"
}
},
]
```
</Tab>
<Tab heading="YAML" group="yaml">
```yaml
apiVersion: consul.hashicorp.com/v1alpha1
kind: ServiceRouter
metadata:
name: web
spec:
routes:
- match:
http:
pathPrefix: /Admin
caseInsensitive: true
destination:
service: admin
```
</Tab>
<Tab heading="JSON" group="json">
```json
{
"Kind": "service-router",
"Name": "web",
"Routes": [
{
"Match": {
"HTTP": {
"PathPrefix": "/Admin",
"CaseInsensitive": true
}
},
"Destination": {
"Service": "admin"
}
}
]
}
```
</Tab>
</Tabs>
### Match a header and query parameter
The following example routes HTTP traffic to the `web` service to a subset of `canary` instances when the requests have `x-debug` in either the header or the URL parameter.