HttpGatewayRoutePathMatch

class aws_cdk.aws_appmesh.HttpGatewayRoutePathMatch

Bases: object

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

ExampleMetadata:

infused

Example:

# 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")
        )
    )
)

Methods

abstract bind(scope)

Returns the gateway route path match configuration.

Parameters:

scope (Construct) –

Return type:

HttpGatewayRoutePathMatchConfig

Static Methods

classmethod exactly(path, rewrite_to=None)

The value of the path must match the specified value exactly.

The provided path must start with the ‘/’ character.

Parameters:
  • path (str) – the exact path to match on.

  • rewrite_to (Optional[str]) – 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.

Return type:

HttpGatewayRoutePathMatch

classmethod regex(regex, rewrite_to=None)

The value of the path must match the specified regex.

Parameters:
  • regex (str) – the regex used to match the path.

  • rewrite_to (Optional[str]) – 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.

Return type:

HttpGatewayRoutePathMatch

classmethod starts_with(prefix, rewrite_to=None)

The value of the path must match the specified prefix.

Parameters:
  • prefix (str) – the value to use to match the beginning of the path part of the URL of the request. It must start with the ‘/’ character. When rewriteTo is provided, it must also end with the ‘/’ character. If provided as “/”, matches all requests. For example, if your virtual service name is “my-service.local” and you want the route to match requests to “my-service.local/metrics”, your prefix should be “/metrics”.

  • rewrite_to (Optional[str]) – Specify either disabling automatic rewrite or rewriting to specified prefix path. To disable automatic rewrite, provide ''. As a default, request’s URL path is automatically rewritten to ‘/’.

Return type:

HttpGatewayRoutePathMatch