From 4700674a85b0fe9b0fd16be1de4034f626ceb1b9 Mon Sep 17 00:00:00 2001 From: Catcher Wong Date: Tue, 7 Mar 2023 17:48:42 +0800 Subject: [PATCH] docs: add NotExists for header routing (#2059) --- docs/docfx/articles/config-files.md | 2 +- docs/docfx/articles/header-routing.md | 53 ++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/docs/docfx/articles/config-files.md b/docs/docfx/articles/config-files.md index 689fbb3cf..ccfe0b6a0 100644 --- a/docs/docfx/articles/config-files.md +++ b/docs/docfx/articles/config-files.md @@ -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 } ], diff --git a/docs/docfx/articles/header-routing.md b/docs/docfx/articles/header-routing.md index 8b0331eb2..892e2b312 100644 --- a/docs/docfx/articles/header-routing.md +++ b/docs/docfx/articles/header-routing.md @@ -100,7 +100,7 @@ Configuration: ] } }, - "route6" : { + "route6" : { "ClusterId": "cluster1", "Match": { "Path": "{**catch-all}", @@ -116,6 +116,18 @@ Configuration: } ] } + }, + "route7" : { + "ClusterId": "cluster1", + "Match": { + "Path": "{**catch-all}", + "Headers": [ + { + "Name": "header7", + "Mode": "NotExists" + } + ] + } } } ``` @@ -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 + } + } + } } }; ``` @@ -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 @@ -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: +```