Search code examples
apigee

Path contains matching


I would like to execute the flow based on a contains match

<Flow name="do_something_flow">
        <Description/>
        <Request>
            <Step>
                <FaultRules/>
                <Name>do_something</Name>
            </Step>
        </Request>
        <Response/>
        <Condition>request.path MatchesPath "/**/india/blr/**"</Condition>
    </Flow>

The flow should execute when ever the request path contains /india/blr for example

/v1/x1/india/blr/z1
/v1/x1/india/blr
/v1/india/blr
/india/blr

The above path expression does not work for the second and last path- where URL starts and ends with subpath. What i really needs is

request.path contains "/india/blr"

Solution

  • In the pre-flow you can have a custom javacallout policy to match the path with contains condition. Then populate a variable Use that variable in the condition of your flow.

    It is a round about way - but works in absence of a "contains" operator in apigee path conditions.

    Alternately, you can try JavaRegex which is supported by apigee in conditions. http://apigee.com/docs/api-services/api/conditions-reference

    ~~ ( JavaRegex operator ) Matches a javax.util.regex compliant regular expression