精简版。我正在尝试创建一个 API 来处理
/goals/risks
/goals/types
/goals/{goalID}
到目前为止,这就是我所拥有的,但它并不是我想要的。因为它给了我 /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 将始终匹配/^\d+$/
,因此如果我可以通过它以某种方式进行路由,它将起作用。最终我也会想添加/goals/{goalID}/item and /goals/{goalID}/items/{itemID}
,但我相信一旦我弄清楚第一步,这将很容易。
如果这里没有办法做到这一点,有没有办法可以在 wso2 到达资源之前重写其中的 url,然后我可以替换/goals/(\d+.*)
为/goals/goal/$1?
我知道我可以通过代理路由它并在 apache 中重写它或但这似乎违背了 WSO2 对我的目的。