I am using a conditional statement as below to raise a fault using "Raise Fault" in Preflow,
(!((proxy.pathsuffix MatchesPath "/abc/xyz") and (request.verb = "POST"))) Or (!((proxy.pathsuffix MatchesPath "/abc") and (request.verb = "POST")))
But this condition is not working even when I give /abc/xyz and "POST",its failing.
But when I have only !((proxy.pathsuffix MatchesPath "/abc/xyz") and (request.verb = "POST")) ,its working fine.
Please let me know why "Or" is creating problem here.
My usecase is I want to throw error only when /abc/xyz POST or /abc POST is not coming in the request.
Hi @RK4
Can you try this and see if it works. I have included the condition for "/" as well. You can remove (proxy.pathsuffix MatchesPath "/") if you think its not needed in the condition.
<Step> <Name>Raise-Fault-1</Name> <Condition>(!((proxy.pathsuffix MatchesPath "/") or (proxy.pathsuffix MatchesPath "/abc") or (proxy.pathsuffix MatchesPath "/abc/xyz")) and (request.verb = "POST"))</Condition> </Step>
Let me know if this worked.
Thanks for your response.
But there is a problem in giving this way.
I dont want to combine entirely like this because we are expecting more resources to be added in future with HTTP verb as "GET","PUT".Then there will be an issue.
Hi @RK4
Looks like you need to raise fault for following requests:
Try this
<Step> <Name>Raise-Fault-1</Name> <Condition>(proxy.pathsuffix Matches "/") or (!(proxy.pathsuffix Matches "/abc" or proxy.pathsuffix Matches "/abc/") and !(proxy.pathsuffix Matches "/abc/xyz" or proxy.pathsuffix Matches "/abc/xyz/")) or (!(proxy.pathsuffix Matches "/abc/" or proxy.pathsuffix Matches "/abc/") and !(request.verb = "GET" or request.verb = "POST")) or (!(proxy.pathsuffix Matches "/abc/xyz" or proxy.pathsuffix Matches "/abc/xyz/") and !(request.verb = "PUT" or request.verb = "DELETE"))</Condition> </Step>
To make it more cleaner, you can split it to multiple steps but use the same policy (something like below). You will be able to make changes easily and in case you want different Fault rules for each, this allows that easily.
<Step> <Name>Raise-Fault-1</Name> <Condition>(proxy.pathsuffix Matches "/" or proxy.pathsuffix Matches "")</Condition> </Step> <Step> <Name>Raise-Fault-1</Name> <Condition>(!(proxy.pathsuffix Matches "/abc" or proxy.pathsuffix Matches "/abc/") and !(proxy.pathsuffix Matches "/abc/xyz" or proxy.pathsuffix Matches "/abc/xyz/"))</Condition> </Step> <Step> <Name>Raise-Fault-1</Name> <Condition>(!(proxy.pathsuffix Matches "/abc/" or proxy.pathsuffix Matches "/abc/") and !(request.verb = "GET" or request.verb = "POST"))</Condition> </Step> <Step> <Name>Raise-Fault-1</Name> <Condition>(!(proxy.pathsuffix Matches "/abc/xyz" or proxy.pathsuffix Matches "/abc/xyz/") and !(request.verb = "PUT" or request.verb = "DELETE"))</Condition> </Step>
Hope this helps
I found the below condition working fine...
((!((proxy.pathsuffix MatchesPath "/abc/xyz") and (request.verb = "POST"))) and (!((proxy.pathsuffix MatchesPath "/abc") and (request.verb = "POST"))))
There should not be "Or" eventhough I find "Or" logical
Every condition should be surrounded by brackets.
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |