How can I add different policies for different flow. And what is the main - how can I map it to proper URL

Not applicable

Hi, I have a bunch of services which have route http://109.166.244.140:9763/webRS/services/user/* . There are many different services will be instead of star. For example hello, validateCredentials, saveUser and so on.

I started to learn flow, but I cann't correctly map flows on my backend API.

That is what I have so far

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TargetEndpoint name="default">
    <Description/>
    <FaultRules/>
    <PreFlow name="PreFlow">
        <!--<Request>-->
        <!--    <Step>-->
        <!--        <Name>SaveRequestVariables</Name>-->
        <!--    </Step>-->
        <!--    <Step>-->
        <!--        <Name>GetUsernameFromJSON</Name>-->
        <!--    </Step>-->
        <!--    <Step>-->
        <!--        <Name>GetCredentials</Name>-->
        <!--    </Step>-->
        <!--    <Step>-->
        <!--        <Name>BasicAuthCredentials</Name>-->
        <!--    </Step>-->
        <!--</Request>-->
        <Request/>
        <Response/>
    </PreFlow>
    <Flows>
        <Flow name="validateCredentials">
            <Description/>
            <Request>
                <Step>
                    <Name>SaveRequestVariables</Name>
                </Step>
                <Step>
                    <Name>GetUsernameFromJSON</Name>
                </Step>
                <Step>
                    <Name>GetCredentials</Name>
                </Step>
                <Step>
                    <Name>BasicAuthCredentials</Name>
                </Step>
            </Request>
            <Response>
                <Step>
                    <Name>OpenCache</Name>
                </Step>
            </Response>
            <Condition>(proxy.pathsuffix MatchesPath "/validateCredentials") and (request.verb = "POST")</Condition>
        </Flow>
        <Flow name="hello">
            <Description/>
            <Request>
                <Step>
                    <Name>GetCredentials</Name>
                </Step>
                <Step>
                    <Name>BasicAuthCredentials</Name>
                </Step>
            </Request>
            <Response/>
            <Condition>(proxy.pathsuffix MatchesPath "/hello") and (request.verb = "GET")</Condition>
        </Flow>
    </Flows>
    <PostFlow name="PostFlow">
        <Request/>
        <!--<Response>-->
        <!--    <Step>-->
        <!--        <Name>OpenCache</Name>-->
        <!--    </Step>-->
        <!--</Response>-->
        <Response/>
    </PostFlow>
    <!--<Flows/>-->
    <HTTPTargetConnection>
        <Properties/>
        <URL>http://109.166.244.140:9763/webRS/services/user/*</URL>
        <!--<URL>http://109.166.244.140:9763/webRS/services/user/validateCredentials</URL>-->
    </HTTPTargetConnection>
</TargetEndpoint>


I commented the code for unique url case. It works. But now I want to create flow functionality. Please help

Solved Solved
1 1 187
1 ACCEPTED SOLUTION

Hi Oleksandr Skoryi,

If you want to route to different targets(backend) like validateCredentials, saveUser etc. then this can be done in two ways:

1. to have separate target endpoints for each service and then based on matching condition you can route the request to that targetEndpoint using RouteRule.

2. to have a single targetEndpoint and dynamically set the variable "target.url" based on conditions using javascript. There is example in the doc to rewrite targeturl using javascript policy.

View solution in original post

1 REPLY 1

Hi Oleksandr Skoryi,

If you want to route to different targets(backend) like validateCredentials, saveUser etc. then this can be done in two ways:

1. to have separate target endpoints for each service and then based on matching condition you can route the request to that targetEndpoint using RouteRule.

2. to have a single targetEndpoint and dynamically set the variable "target.url" based on conditions using javascript. There is example in the doc to rewrite targeturl using javascript policy.