Skip to content

Commit

Permalink
docs: add NotExists for header routing (#2059)
Browse files Browse the repository at this point in the history
  • Loading branch information
catcherwong authored Mar 7, 2023
1 parent 6e4a77f commit 4700674
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/docfx/articles/config-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ For additional fields see [ClusterConfig](xref:Yarp.ReverseProxy.Configuration.C
{
"Name": "MyCustomHeader", // Name of the header
"Values": [ "value1", "value2", "another value" ], // Matches are against any of these values
"Mode": "ExactHeader", // or "HeaderPrefix", "Exists" , "Contains", "NotContains"
"Mode": "ExactHeader", // or "HeaderPrefix", "Exists" , "Contains", "NotContains", "NotExists"
"IsCaseSensitive": true
}
],
Expand Down
53 changes: 51 additions & 2 deletions docs/docfx/articles/header-routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Configuration:
]
}
},
"route6" : {
"route6" : {
"ClusterId": "cluster1",
"Match": {
"Path": "{**catch-all}",
Expand All @@ -116,6 +116,18 @@ Configuration:
}
]
}
},
"route7" : {
"ClusterId": "cluster1",
"Match": {
"Path": "{**catch-all}",
"Headers": [
{
"Name": "header7",
"Mode": "NotExists"
}
]
}
}
}
```
Expand Down Expand Up @@ -235,6 +247,23 @@ var routes = new[]
}
}
}
},
new RouteConfig()
{
RouteId = "route7",
ClusterId = "cluster1",
Match = new RouteMatch
{
Path = "{**catch-all}",
Headers = new[]
{
new RouteHeader()
{
Name = "Header7",
Mode = HeaderMatchMode.NotExists
}
}
}
}
};
```
Expand All @@ -249,7 +278,7 @@ The header name to check for on the request. A non-empty value is required. This

### Values

A list of possible values to search for. The header must match at least one of these values according to the specified `Mode` except for the 'NotContains'. At least one value is required unless `Mode` is set to `Exists`.
A list of possible values to search for. The header must match at least one of these values according to the specified `Mode` except for the 'NotContains'. At least one value is required unless `Mode` is set to `Exists` or `NotExists`.

### Mode

Expand Down Expand Up @@ -373,3 +402,23 @@ Header4: value2
```
Header5: AnyValue
```

### Scenario 5 - NotExists

Route7 requires that the header "Header7" must not exists

The following headers will match route7:

```
NotHeader7: AnyValue
```


The following headers will _not_ match route7 because the header "Header7" exists.

```
Header7: AnyValue
```
```
Header7:
```

0 comments on commit 4700674

Please sign in to comment.