Skip to content

Commit c05dc6b

Browse files
committed
docs: add method matching example for HTTPProxy
Signed-off-by: Shivam Kumar <[email protected]>
1 parent 9b28a35 commit c05dc6b

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

site/content/docs/main/config/request-routing.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,36 @@ Modifiers:
126126
- `ignoreCase`: IgnoreCase specifies that string matching should be case insensitive. It has no effect on the `Regex` parameter.
127127
- `treatMissingAsEmpty`: specifies if the header match rule specified header does not exist, this header value will be treated as empty. Defaults to false. Unlike the underlying Envoy implementation this is **only** supported for negative matches (e.g. NotContains, NotExact).
128128

129+
#### Method Matching
130+
131+
HTTPProxy currently does not provide a dedicated field for matching HTTP methods. However, you can achieve method-based routing using **header conditions** with the Envoy pseudo-header `:method`. This allows routing requests based on HTTP methods such as `GET`, `POST`, `PUT`, etc.
132+
133+
```yaml
134+
apiVersion: projectcontour.io/v1
135+
kind: HTTPProxy
136+
metadata:
137+
name: method-matching
138+
namespace: default
139+
spec:
140+
virtualhost:
141+
fqdn: methods.example.com
142+
routes:
143+
- conditions:
144+
- header:
145+
name: ":method"
146+
exact: GET
147+
services:
148+
- name: get-service
149+
port: 80
150+
- conditions:
151+
- header:
152+
name: ":method"
153+
exact: POST
154+
services:
155+
- name: post-service
156+
port: 80
157+
```
158+
129159
#### Query parameter conditions
130160

131161
Similar to the `header` conditions, `queryParameter` conditions also require the

0 commit comments

Comments
 (0)