Routing API Proxy Requests to Resources defined as just a slash ( / )

1 0 915

When designing an API Proxy, a resource path of just a slash ( / ) may be defined, and one may want requests made to both the slash proxy.pathsuffix as well as the root base path to be directed to the slash resource. Here's an example setup.

303-screen-shot-2015-04-10-at-31238-pm.png

API calls to both the following URLs should be routed to the "resourceone" resource.

http://org-test.apigee.net/somepath

http://org-test.apigee.net/somepath/

The flow Condition will get defined as follows for the "resourceone" resource.

<Flow name="resourceone">
    <Description/>
    <Request/>
    <Response/>
    <Condition>(proxy.pathsuffix MatchesPath "/") and (request.verb = "POST")</Condition>
</Flow>

The behavior of this is that incoming requests http://org-test.apigee.net/somepath will be routed to the "resourceone" flow, but requests for http://org-test.apigee.net/somepath/ will not be routed to any of the conditional flows.

This has to do with how the MatchesPath operator evaluates the proxy.pathsuffix. It doesn't play well with a pathsuffix of just slash. To get around this, define the flow condition as follows.

<Flow name="resourceone">
    <Description/>
    <Request/>
    <Response/>
    <Condition>((proxy.pathsuffix == "") or (proxy.pathsuffix == "/")) and (request.verb = "POST")</Condition>
</Flow>
Version history
Last update:
‎04-10-2015 03:49 PM
Updated by: