HeaderMatch Class
Used to generate header matching methods.
| Source | aws-appmesh/lib/header-match.ts |
|---|
Example
ts
declare const router: appmesh.VirtualRouter;
declare const node: appmesh.VirtualNode;
router.addRoute('route-http2', {
routeSpec: appmesh.RouteSpec.http2({
weightedTargets: [
{
virtualNode: node,
},
],
match: {
path: appmesh.HttpRoutePathMatch.exactly('/exact'),
method: appmesh.HttpRouteMethod.POST,
protocol: appmesh.HttpRouteProtocol.HTTPS,
headers: [
// All specified headers must match for the route to match.
appmesh.HeaderMatch.valueIs('Content-Type', 'application/json'),
appmesh.HeaderMatch.valueIsNot('Content-Type', 'application/json'),
],
queryParameters: [
// All specified query parameters must match for the route to match.
appmesh.QueryParameterMatch.valueIs('query-field', 'value')
],
},
}),
});
python
# router: appmesh.VirtualRouter
# node: appmesh.VirtualNode
router.add_route("route-http2",
route_spec=appmesh.RouteSpec.http2(
weighted_targets=[appmesh.WeightedTarget(
virtual_node=node
)
],
match=appmesh.HttpRouteMatch(
path=appmesh.HttpRoutePathMatch.exactly("/exact"),
method=appmesh.HttpRouteMethod.POST,
protocol=appmesh.HttpRouteProtocol.HTTPS,
headers=[
# All specified headers must match for the route to match.
appmesh.HeaderMatch.value_is("Content-Type", "application/json"),
appmesh.HeaderMatch.value_is_not("Content-Type", "application/json")
],
query_parameters=[
# All specified query parameters must match for the route to match.
appmesh.QueryParameterMatch.value_is("query-field", "value")
]
)
)
)
java
VirtualRouter router;
VirtualNode node;
router.addRoute("route-http2", RouteBaseProps.builder()
.routeSpec(RouteSpec.http2(HttpRouteSpecOptions.builder()
.weightedTargets(List.of(WeightedTarget.builder()
.virtualNode(node)
.build()))
.match(HttpRouteMatch.builder()
.path(HttpRoutePathMatch.exactly("/exact"))
.method(HttpRouteMethod.POST)
.protocol(HttpRouteProtocol.HTTPS)
.headers(List.of(HeaderMatch.valueIs("Content-Type", "application/json"), HeaderMatch.valueIsNot("Content-Type", "application/json")))
.queryParameters(List.of(QueryParameterMatch.valueIs("query-field", "value")))
.build())
.build()))
.build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
VirtualRouter router;
VirtualNode node;
router.AddRoute("route-http2", new RouteBaseProps {
RouteSpec = RouteSpec.Http2(new HttpRouteSpecOptions {
WeightedTargets = new [] { new WeightedTarget {
VirtualNode = node
} },
Match = new HttpRouteMatch {
Path = HttpRoutePathMatch.Exactly("/exact"),
Method = HttpRouteMethod.POST,
Protocol = HttpRouteProtocol.HTTPS,
Headers = new [] { HeaderMatch.ValueIs("Content-Type", "application/json"), HeaderMatch.ValueIsNot("Content-Type", "application/json") },
QueryParameters = new [] { QueryParameterMatch.ValueIs("query-field", "value") }
}
})
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var router VirtualRouter
var node VirtualNode
router.addRoute(jsii.String("route-http2"), &RouteBaseProps{
RouteSpec: appmesh.RouteSpec_Http2(&HttpRouteSpecOptions{
WeightedTargets: []WeightedTarget{
&WeightedTarget{
VirtualNode: node,
},
},
Match: &HttpRouteMatch{
Path: appmesh.HttpRoutePathMatch_Exactly(jsii.String("/exact")),
Method: appmesh.HttpRouteMethod_POST,
Protocol: appmesh.HttpRouteProtocol_HTTPS,
Headers: []HeaderMatch{
appmesh.HeaderMatch_ValueIs(jsii.String("Content-Type"), jsii.String("application/json")),
appmesh.HeaderMatch_ValueIsNot(jsii.String("Content-Type"), jsii.String("application/json")),
},
QueryParameters: []QueryParameterMatch{
appmesh.QueryParameterMatch_ValueIs(jsii.String("query-field"), jsii.String("value")),
},
},
}),
})
Initializer
ts
new HeaderMatch()
python
HeaderMatch()
java
new HeaderMatch()
csharp
new HeaderMatch()
go
NewHeaderMatch()
Methods
bind(scope: Construct): HeaderMatchConfigdef bind(self, scope: Construct) -> HeaderMatchConfigpublic HeaderMatchConfig bind(Construct scope)public HeaderMatchConfig Bind(Construct scope)func Bind(Scope Construct) HeaderMatchConfig #Returns the header match configuration.
valueDoesNotEndWith(headerName: string, suffix: string): HeaderMatch // chainable@staticmethod def value_does_not_end_with(header_name: str, suffix: str) -> HeaderMatchpublic static HeaderMatch valueDoesNotEndWith(String headerName, String suffix)public static HeaderMatch ValueDoesNotEndWith(string headerName, string suffix)func ValueDoesNotEndWith(HeaderName *string, Suffix *string) HeaderMatch static #The value of the header with the given name in the request must not end with the specified characters.
2 parameters
Parameters
headerNameheader_nameheaderNameheaderNameHeaderName— the name of the header to match against.suffixsuffixsuffixsuffixSuffix— The suffix to test against.
valueDoesNotMatchRegex(headerName: string, regex: string): HeaderMatch // chainable@staticmethod def value_does_not_match_regex(header_name: str, regex: str) -> HeaderMatchpublic static HeaderMatch valueDoesNotMatchRegex(String headerName, String regex)public static HeaderMatch ValueDoesNotMatchRegex(string headerName, string regex)func ValueDoesNotMatchRegex(HeaderName *string, Regex *string) HeaderMatch static #The value of the header with the given name in the request must not include the specified characters.
2 parameters
Parameters
headerNameheader_nameheaderNameheaderNameHeaderName— the name of the header to match against.regexregexregexregexRegex— The regex to test against.
valueDoesNotStartWith(headerName: string, prefix: string): HeaderMatch // chainable@staticmethod def value_does_not_start_with(header_name: str, prefix: str) -> HeaderMatchpublic static HeaderMatch valueDoesNotStartWith(String headerName, String prefix)public static HeaderMatch ValueDoesNotStartWith(string headerName, string prefix)func ValueDoesNotStartWith(HeaderName *string, Prefix *string) HeaderMatch static #The value of the header with the given name in the request must not start with the specified characters.
2 parameters
Parameters
headerNameheader_nameheaderNameheaderNameHeaderName— the name of the header to match against.prefixprefixprefixprefixPrefix— The prefix to test against.
valueEndsWith(headerName: string, suffix: string): HeaderMatch // chainable@staticmethod def value_ends_with(header_name: str, suffix: str) -> HeaderMatchpublic static HeaderMatch valueEndsWith(String headerName, String suffix)public static HeaderMatch ValueEndsWith(string headerName, string suffix)func ValueEndsWith(HeaderName *string, Suffix *string) HeaderMatch static #The value of the header with the given name in the request must end with the specified characters.
2 parameters
Parameters
headerNameheader_nameheaderNameheaderNameHeaderName— the name of the header to match against.suffixsuffixsuffixsuffixSuffix— The suffix to test against.
valueIs(headerName: string, headerValue: string): HeaderMatch // chainable@staticmethod def value_is(header_name: str, header_value: str) -> HeaderMatchpublic static HeaderMatch valueIs(String headerName, String headerValue)public static HeaderMatch ValueIs(string headerName, string headerValue)func ValueIs(HeaderName *string, HeaderValue *string) HeaderMatch static #The value of the header with the given name in the request must match the specified value exactly.
2 parameters
Parameters
headerNameheader_nameheaderNameheaderNameHeaderName— the name of the header to match against.headerValueheader_valueheaderValueheaderValueHeaderValue— The exact value to test against.
valueIsNot(headerName: string, headerValue: string): HeaderMatch // chainable@staticmethod def value_is_not(header_name: str, header_value: str) -> HeaderMatchpublic static HeaderMatch valueIsNot(String headerName, String headerValue)public static HeaderMatch ValueIsNot(string headerName, string headerValue)func ValueIsNot(HeaderName *string, HeaderValue *string) HeaderMatch static #The value of the header with the given name in the request must not match the specified value exactly.
2 parameters
Parameters
headerNameheader_nameheaderNameheaderNameHeaderName— the name of the header to match against.headerValueheader_valueheaderValueheaderValueHeaderValue— The exact value to test against.
valueMatchesRegex(headerName: string, regex: string): HeaderMatch // chainable@staticmethod def value_matches_regex(header_name: str, regex: str) -> HeaderMatchpublic static HeaderMatch valueMatchesRegex(String headerName, String regex)public static HeaderMatch ValueMatchesRegex(string headerName, string regex)func ValueMatchesRegex(HeaderName *string, Regex *string) HeaderMatch static #The value of the header with the given name in the request must include the specified characters.
2 parameters
Parameters
headerNameheader_nameheaderNameheaderNameHeaderName— the name of the header to match against.regexregexregexregexRegex— The regex to test against.
valuesIsInRange(headerName: string, start: number, end: number): HeaderMatch // chainable@staticmethod def values_is_in_range(header_name: str, start: int | float, end: int | float) -> HeaderMatchpublic static HeaderMatch valuesIsInRange(String headerName, Number start, Number end)public static HeaderMatch ValuesIsInRange(string headerName, double start, double end)func ValuesIsInRange(HeaderName *string, Start *float64, End *float64) HeaderMatch static #The value of the header with the given name in the request must be in a range of values.
3 parameters
Parameters
headerNameheader_nameheaderNameheaderNameHeaderName— the name of the header to match against.startstartstartstartStart— Match on values starting at and including this value.endendendendEnd— Match on values up to but not including this value.
valuesIsNotInRange(headerName: string, start: number, end: number): HeaderMatch // chainable@staticmethod def values_is_not_in_range(header_name: str, start: int | float, end: int | float) -> HeaderMatchpublic static HeaderMatch valuesIsNotInRange(String headerName, Number start, Number end)public static HeaderMatch ValuesIsNotInRange(string headerName, double start, double end)func ValuesIsNotInRange(HeaderName *string, Start *float64, End *float64) HeaderMatch static #The value of the header with the given name in the request must not be in a range of values.
3 parameters
Parameters
headerNameheader_nameheaderNameheaderNameHeaderName— the name of the header to match against.startstartstartstartStart— Match on values starting at and including this value.endendendendEnd— Match on values up to but not including this value.
valueStartsWith(headerName: string, prefix: string): HeaderMatch // chainable@staticmethod def value_starts_with(header_name: str, prefix: str) -> HeaderMatchpublic static HeaderMatch valueStartsWith(String headerName, String prefix)public static HeaderMatch ValueStartsWith(string headerName, string prefix)func ValueStartsWith(HeaderName *string, Prefix *string) HeaderMatch static #The value of the header with the given name in the request must start with the specified characters.
2 parameters
Parameters
headerNameheader_nameheaderNameheaderNameHeaderName— the name of the header to match against.prefixprefixprefixprefixPrefix— The prefix to test against.