Short Version. I am trying to create a API that will handle
/goals/risks
/goals/types
/goals/{goalID}
So far this is what I have but it isn't quite what I am looking for. as it gives me /goals/goal/{goalId}
<api xmlns="http://ws.apache.org/ns/synapse" name="GoalAPI" context="/goals">
<resource methods="GET" uri-template="/risks" faultSequence="ReturnError">...</resource>
<resource methods="GET" uri-template="/types" faultSequence="ReturnError">...</resource>
<resource methods="GET" uri-template="/goal/{goalId}" faultSequence="ReturnError">...</resource>
</api>
GoalID will always match /^\d+$/
so if I can route by that somehow it will work. eventually I will want to add /goals/{goalID}/item and /goals/{goalID}/items/{itemID}
also but I believe that will be easy enough once I figure out the first step.
If there is no way to do this here, is there a way I can rewrite the url inside wso2 before it reaches the resource and I would be able to then replace /goals/(\d+.*)
with /goals/goal/$1?
I know I could route it though a proxy and rewrite it in apache or something but that seems to defeat WSO2's purpose to me.
So after looking into this more without success and getting no response on I just stared at the code can came up with...
<api xmlns="http://ws.apache.org/ns/synapse" name="GoalAPI" context="/goals">
<resource methods="GET" uri-template="/{goalID}" faultSequence="ReturnError">
<inSequence>
<switch source="get-property('uri.var.goalId')">
<case regex="risks">...</case>
<case regex="types">...</case>
<default>...Handle the ID here...</default>
</switch>
</inSequence>
...
</resource>
</api>