HttpGatewayRoutePathMatch Class
Defines HTTP gateway route matching based on the URL path of the request.
Example
ts
declare const gateway: appmesh.VirtualGateway;
declare const virtualService: appmesh.VirtualService;
gateway.addGatewayRoute('gateway-route-http-2', {
routeSpec: appmesh.GatewayRouteSpec.http({
routeTarget: virtualService,
match: {
// This rewrites the path from '/test' to '/rewrittenPath'.
path: appmesh.HttpGatewayRoutePathMatch.exactly('/test', '/rewrittenPath'),
},
}),
});
python
# gateway: appmesh.VirtualGateway
# virtual_service: appmesh.VirtualService
gateway.add_gateway_route("gateway-route-http-2",
route_spec=appmesh.GatewayRouteSpec.http(
route_target=virtual_service,
match=appmesh.HttpGatewayRouteMatch(
# This rewrites the path from '/test' to '/rewrittenPath'.
path=appmesh.HttpGatewayRoutePathMatch.exactly("/test", "/rewrittenPath")
)
)
)
java
VirtualGateway gateway;
VirtualService virtualService;
gateway.addGatewayRoute("gateway-route-http-2", GatewayRouteBaseProps.builder()
.routeSpec(GatewayRouteSpec.http(HttpGatewayRouteSpecOptions.builder()
.routeTarget(virtualService)
.match(HttpGatewayRouteMatch.builder()
// This rewrites the path from '/test' to '/rewrittenPath'.
.path(HttpGatewayRoutePathMatch.exactly("/test", "/rewrittenPath"))
.build())
.build()))
.build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
VirtualGateway gateway;
VirtualService virtualService;
gateway.AddGatewayRoute("gateway-route-http-2", new GatewayRouteBaseProps {
RouteSpec = GatewayRouteSpec.Http(new HttpGatewayRouteSpecOptions {
RouteTarget = virtualService,
Match = new HttpGatewayRouteMatch {
// This rewrites the path from '/test' to '/rewrittenPath'.
Path = HttpGatewayRoutePathMatch.Exactly("/test", "/rewrittenPath")
}
})
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var gateway VirtualGateway
var virtualService VirtualService
gateway.addGatewayRoute(jsii.String("gateway-route-http-2"), &GatewayRouteBaseProps{
RouteSpec: appmesh.GatewayRouteSpec_Http(&HttpGatewayRouteSpecOptions{
RouteTarget: virtualService,
Match: &HttpGatewayRouteMatch{
// This rewrites the path from '/test' to '/rewrittenPath'.
Path: appmesh.HttpGatewayRoutePathMatch_Exactly(jsii.String("/test"), jsii.String("/rewrittenPath")),
},
}),
})
Initializer
ts
new HttpGatewayRoutePathMatch()
python
HttpGatewayRoutePathMatch()
java
new HttpGatewayRoutePathMatch()
csharp
new HttpGatewayRoutePathMatch()
go
NewHttpGatewayRoutePathMatch()
Methods
bind(scope: Construct): HttpGatewayRoutePathMatchConfigdef bind(self, scope: Construct) -> HttpGatewayRoutePathMatchConfigpublic HttpGatewayRoutePathMatchConfig bind(Construct scope)public HttpGatewayRoutePathMatchConfig Bind(Construct scope)func Bind(Scope Construct) HttpGatewayRoutePathMatchConfig#Returns the gateway route path match configuration.
exactly(path: string, rewriteTo?: string): HttpGatewayRoutePathMatch // chainable@staticmethod def exactly(path: str, rewrite_to: typing.Optional[str] = None) -> HttpGatewayRoutePathMatchpublic static HttpGatewayRoutePathMatch exactly(String path, String rewriteTo)public static HttpGatewayRoutePathMatch Exactly(string path, string? rewriteTo = null)func Exactly(Path *string, RewriteTo *string) HttpGatewayRoutePathMatchstatic#The value of the path must match the specified value exactly.
The provided path must start with the '/' character.
2 parameters
Parameters
pathpathpathpathPath— the exact path to match on.rewriteTorewrite_torewriteTorewriteToRewriteTo— the value to substitute for the matched part of the path of the gateway request URL As a default, retains original request's URL path.
regex(regex: string, rewriteTo?: string): HttpGatewayRoutePathMatch // chainable@staticmethod def regex(regex: str, rewrite_to: typing.Optional[str] = None) -> HttpGatewayRoutePathMatchpublic static HttpGatewayRoutePathMatch regex(String regex, String rewriteTo)public static HttpGatewayRoutePathMatch Regex(string regex, string? rewriteTo = null)func Regex(Regex *string, RewriteTo *string) HttpGatewayRoutePathMatchstatic#The value of the path must match the specified regex.
2 parameters
Parameters
regexregexregexregexRegex— the regex used to match the path.rewriteTorewrite_torewriteTorewriteToRewriteTo— the value to substitute for the matched part of the path of the gateway request URL As a default, retains original request's URL path.
startsWith(prefix: string, rewriteTo?: string): HttpGatewayRoutePathMatch // chainable@staticmethod def starts_with(prefix: str, rewrite_to: typing.Optional[str] = None) -> HttpGatewayRoutePathMatchpublic static HttpGatewayRoutePathMatch startsWith(String prefix, String rewriteTo)public static HttpGatewayRoutePathMatch StartsWith(string prefix, string? rewriteTo = null)func StartsWith(Prefix *string, RewriteTo *string) HttpGatewayRoutePathMatchstatic#The value of the path must match the specified prefix.
2 parameters
Parameters
prefixprefixprefixprefixPrefix— the value to use to match the beginning of the path part of the URL of the request.rewriteTorewrite_torewriteTorewriteToRewriteTo— Specify either disabling automatic rewrite or rewriting to specified prefix path.