im on WSO2 ESB 4.8.1. I need to block some request if their path match a regular expression. So i've implemented this proxy and these sequences:
In my proxy:
<target>
<inSequence>
<sequence key="MySequence"></sequence>
<send>
<endpoint key="epProva"></endpoint>
</send>
</inSequence>
Where MySequence is:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="MySequence">
<conditionalRouter continueAfter="false">
<conditionalRoute breakRoute="true" asynchronous="true">
<condition>
<match type="url" regex=".*/my/path/.*"></match>
</condition>
<target sequence="conf:/BannedListMessage"></target>
</conditionalRoute>
</conditionalRouter>
</sequence>
where BannedListMessage is:
<sequence xmlns="http://ws.apache.org/ns/synapse">
<header name="To" action="remove"></header>
<property name="HTTP_SC" value="401" scope="axis2"></property>
<property name="RESPONSE" value="true"></property>
<property name="NO_ENTITY_BODY" action="remove" scope="axis2"></property>
<payloadFactory media-type="json">
<format>
{"code":"401", "unhautorized."}
</format>
</payloadFactory>
<property name="messageType" value="application/json" scope="axis2"></property>
<send></send>
</sequence>
MySquence has the job to check if the request url matches the regular expression and, in that case, it has to block the request's flow, before it can reach the server, and to call the BannedListMessage sequence which will send back an error response (401) to the client.
During my attempts i noticed that
if the attribute continueAfter=true in MySequence i get the 401 "unauthorized" error as response but the request reach the server.
If i set continueAfter="false" i receive a 202 Accepted response and the request doesn't reach the server.
My target is to send the BannedListMessage 401 error to the client and to block the request. What have i to do?