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

Upstream path examples

Native endpoint, Upstream Path with multiple named parameters

Endpoint Path: /users/{userId}/orders/{orderId}. Upstream Path: /v2/customers/{userId}/purchases/{orderId}. A request to https://elastic.snaplogic.com/myservice/users/alice/orders/42 resolves to /v2/customers/alice/purchases/42, which the pipeline receives as PATH_INFO. Note that the Upstream Path can rename and reorder segments as long as every placeholder it uses also appears in the Path.

Native endpoint, static Upstream Path with trailing segments

Endpoint Path: /orders. Upstream Path: /v2/orders. A request to https://elastic.snaplogic.com/myservice/orders/42/items/9 matches the route with /42/items/9 as trailing segments. The resolved path is /v2/orders/42/items/9, which the pipeline receives as PATH_INFO.

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.