Path examples

Examples that illustrate path matching and resolution behavior for native and external endpoints.

Advanced routing example

Advanced routing determines which endpoint to invoke based on rules or expressions. A rule is a name-value pair for a query parameter, header, or path parameter.

For example, a calculator Service might have two endpoints, one that accepts JSON input and one that accepts XML input. You can use the same path name for both and have APIM 3.0 route requests based on a value, such as the Content-Type in the header. The rule or expression that you supply must evaluate to true for the request to be routed to that path.

The following image shows two paths, one for the JSON route and one for the XML route. The rule evaluates the header value for Content-Type to determine which path to route the request to.


Advanced routing path examples

Path resolution examples

Native endpoint, path with named parameters

Endpoint Path: /users/{userId}/orders/{orderId}. A request to https://elastic.snaplogic.com/myservice/users/alice/orders/42 resolves the path parameters and the pipeline receives PATH_INFO with value /users/alice/orders/42.

Native endpoint, path with trailing segments

Endpoint Path: /orders. A request to https://elastic.snaplogic.com/myservice/orders/42/items/9 matches the route with /42/items/9 as trailing segments. The pipeline receives PATH_INFO with value /orders/42/items/9.

Refer to Pass pipeline arguments to Triggered Task for details on reading PATH_INFO in a pipeline.

Native endpoint, custom Upstream Path

Endpoint Path: /users/{userId}/orders/{orderId}. Upstream Path: /orders/{orderId}. A request to https://elastic.snaplogic.com/myservice/users/alice/orders/42 resolves the path parameters and the pipeline receives PATH_INFO with value /orders/42. The userId segment is not forwarded because it is not in the Upstream Path template.

External endpoint, Upstream URL + Upstream Path

Endpoint Upstream URL: https://api.example.com/v1. Path: /orders/{orderId}. Upstream Path: /orders/{orderId}/details. A request to https://elastic.snaplogic.com/myservice/orders/42 forwards to https://api.example.com/v1/orders/42/details.