Can anyone explain where to exactly place the condition in the pre/post flows?

Hi Team, 

I have observed the condition is being used in two ways

<PreFlow name="MyPreFlow">
<Request>
<Step>
<Name>Spike-Arrest</Name>
<Condition>request.verb == "OPTIONS"</Condition> -- 1
</Step>
</Request>
<Step>
<Condition>request.verb == "GET"</Condition>   -- 2
<Name>GET</Name>
</Step>
</PreFlow>

I have executed the API in TRACE mode as well but didn't get the difference based on the logs for both the cases. 

Could anyone clarify whether is there any difference between the both methods and are the code executing line by line in APIGEE!!?

Thanks,

Dinesh

0 3 76
3 REPLIES 3

Can anyone explain where to exactly place the condition in the pre/post flows?

yes

 

<PreFlow name="MyPreFlow">
  <Request>
    <Step>
      <Name>Spike-Arrest</Name>
      <Condition>request.verb == "OPTIONS"</Condition> -- 1
    </Step>
  </Request>
  <!-- the following element is not valid, not appropriate here -->
  <Step>
    <Condition>request.verb == "GET"</Condition>   -- 2
    <Name>GET</Name>
  </Step>
</PreFlow>

The Condition is OK, valid, under Step. 

The Step is OK, Valid, under Request. 

The Request is OK, Valid, under PreFlow.

The other Step is not OK under PreFlow.  You need to remove that. 

You could move it so that it is under Request, if that's what you want. 

If you explain specifically what you want to do, then someone here might be able to provide better guidance for you, on where to insert your Steps and Conditions, etc. 

 

Hi,

Sorry that was a typo while doing copy paste

My query was mainly on where to place the condition in the Step tag

Please correct me if I'm wrong. My understanding was the condition should always come first ahead of the Name tag so that it validates the condition first and then goes to the policy if condition is satisfied.

Is the below scenario valid (where Name comes after condition in the step) !? My understanding is the policy will be executed before validating condition in this case which is not ideal scenario in real time

 <Step>
      <Name>Spike-Arrest</Name>
      <Condition>request.verb == "OPTIONS"</Condition> -- 1
    </Step>

Thanks,

Dinesh

The ordering of the Name and Condition elements is not relevant. Both work. Easy to test !