Skip to content
v2.277.0

HttpRoutePathMatch Class ​

Defines HTTP route matching based on the URL path of the request.

Example ​

ts
declare const router: appmesh.VirtualRouter;
declare const node: appmesh.VirtualNode;

router.addRoute('route-http', {
  routeSpec: appmesh.RouteSpec.http({
    weightedTargets: [
      {
        virtualNode: node,
        weight: 50,
      },
      {
        virtualNode: node,
        weight: 50,
      },
    ],
    match: {
      path: appmesh.HttpRoutePathMatch.startsWith('/path-to-app'),
    },
  }),
});
python
# router: appmesh.VirtualRouter
# node: appmesh.VirtualNode


router.add_route("route-http",
    route_spec=appmesh.RouteSpec.http(
        weighted_targets=[appmesh.WeightedTarget(
            virtual_node=node,
            weight=50
        ), appmesh.WeightedTarget(
            virtual_node=node,
            weight=50
        )
        ],
        match=appmesh.HttpRouteMatch(
            path=appmesh.HttpRoutePathMatch.starts_with("/path-to-app")
        )
    )
)
java
VirtualRouter router;
VirtualNode node;


router.addRoute("route-http", RouteBaseProps.builder()
        .routeSpec(RouteSpec.http(HttpRouteSpecOptions.builder()
                .weightedTargets(List.of(WeightedTarget.builder()
                        .virtualNode(node)
                        .weight(50)
                        .build(), WeightedTarget.builder()
                        .virtualNode(node)
                        .weight(50)
                        .build()))
                .match(HttpRouteMatch.builder()
                        .path(HttpRoutePathMatch.startsWith("/path-to-app"))
                        .build())
                .build()))
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
VirtualRouter router;
VirtualNode node;


router.AddRoute("route-http", new RouteBaseProps {
    RouteSpec = RouteSpec.Http(new HttpRouteSpecOptions {
        WeightedTargets = new [] { new WeightedTarget {
            VirtualNode = node,
            Weight = 50
        }, new WeightedTarget {
            VirtualNode = node,
            Weight = 50
        } },
        Match = new HttpRouteMatch {
            Path = HttpRoutePathMatch.StartsWith("/path-to-app")
        }
    })
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var router VirtualRouter
var node VirtualNode


router.addRoute(jsii.String("route-http"), &RouteBaseProps{
	RouteSpec: appmesh.RouteSpec_Http(&HttpRouteSpecOptions{
		WeightedTargets: []WeightedTarget{
			&WeightedTarget{
				VirtualNode: node,
				Weight: jsii.Number(50),
			},
			&WeightedTarget{
				VirtualNode: node,
				Weight: jsii.Number(50),
			},
		},
		Match: &HttpRouteMatch{
			Path: appmesh.HttpRoutePathMatch_StartsWith(jsii.String("/path-to-app")),
		},
	}),
})

Initializer ​

ts
new HttpRoutePathMatch()
python
HttpRoutePathMatch()
java
new HttpRoutePathMatch()
csharp
new HttpRoutePathMatch()
go
NewHttpRoutePathMatch()

Methods ​

bind(scope: Construct): HttpRoutePathMatchConfigdef bind(self, scope: Construct) -> HttpRoutePathMatchConfigpublic HttpRoutePathMatchConfig bind(Construct scope)public HttpRoutePathMatchConfig Bind(Construct scope)func Bind(Scope Construct) HttpRoutePathMatchConfig #
Returns the route path match configuration.
exactly(path: string): HttpRoutePathMatch // chainable@staticmethod def exactly(path: str) -> HttpRoutePathMatchpublic static HttpRoutePathMatch exactly(String path)public static HttpRoutePathMatch Exactly(string path)func Exactly(Path *string) HttpRoutePathMatch static #
The value of the path must match the specified value exactly.

The provided path must start with the '/' character.

1 parameter

Parameters

  • pathpathpathpathPath — the exact path to match on.
regex(regex: string): HttpRoutePathMatch // chainable@staticmethod def regex(regex: str) -> HttpRoutePathMatchpublic static HttpRoutePathMatch regex(String regex)public static HttpRoutePathMatch Regex(string regex)func Regex(Regex *string) HttpRoutePathMatch static #
The value of the path must match the specified regex.
1 parameter

Parameters

  • regexregexregexregexRegex — the regex used to match the path.
startsWith(prefix: string): HttpRoutePathMatch // chainable@staticmethod def starts_with(prefix: str) -> HttpRoutePathMatchpublic static HttpRoutePathMatch startsWith(String prefix)public static HttpRoutePathMatch StartsWith(string prefix)func StartsWith(Prefix *string) HttpRoutePathMatch static #
The value of the path must match the specified prefix.
1 parameter

Parameters

  • prefixprefixprefixprefixPrefix — the value to use to match the beginning of the path part of the URL of the request.