Skip to content

Commit 7690844

Browse files
committed
Added soem more readme on new annotations.
1 parent 750c1b9 commit 7690844

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ metadata:
6969
# Specify a particular listener name
7070
# for generated routes.
7171
i2g-operator/section-name: "my-section"
72+
# Here's how to add additional matchers.
73+
i2g-operator-matches-header/2: "X-Forwarded-For=1.2.3.4"
74+
# Here's how to add additional matchers.
75+
i2g-operator-matches-query/2: "myQuery~=^(test.hehe|test.memes)"
76+
7277
name: test-ingress
7378
spec:
7479
ingressClassName: nginx
@@ -89,3 +94,20 @@ spec:
8994
secretName: test-tls-secret
9095

9196
```
97+
98+
### Matchers
99+
100+
To add additional requrest matchers to HTTPRoute, you can use annotations. Here are two of them:
101+
102+
* `i2g-operator-matches-header/{weight}`
103+
* `i2g-operator-matches-query/{weight}`
104+
105+
Basically, you can create multiple rules specifying the weight for ordering. It's useful if you want, for example,
106+
craete a rule for additional matches against X-Forwarded-For set by your proxy.
107+
108+
Each rule is a key-value pair where key is header (or queryParam) name and value is it's value. There are 2 ways of matching.
109+
110+
1. key=value
111+
2. key~=value
112+
113+
The difference is that `=` rules are translated to `Exact` match and `~=` rules are translated to Regularexpression matches.

src/value_filters.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,8 @@ impl FromStr for MatchRule {
101101
type Err = I2GError;
102102

103103
fn from_str(rule: &str) -> Result<Self, Self::Err> {
104-
let parts = rule.split('=').collect::<Vec<_>>();
105-
match *parts.as_slice() {
106-
[key, value] => {
104+
match rule.split_once('=') {
105+
Some((key, value)) => {
107106
if key.ends_with('~') {
108107
return Ok(MatchRule::RegularExpression(
109108
key.strip_suffix('~').unwrap().to_string(),

0 commit comments

Comments
 (0)