Mule ApiKit - 同时为 ../api/items 和 ../api/items/{itemId} 设置端点?

Mule ApiKit - Endpoints for ../api/items and ../api/items/{itemId} at the same time?

在 mule 中,我们如何同时为 ../api/items 和 ../api/items/{itemId} 提供端点?

我想知道如何让 ApiKit 为端点工作。当我调用 ../api/items 时,我得到了 nullpayload 和一个例外,这在 https://support.mulesoft.com/s/article/ka434000000TPOz/Method-not-Allowed-on-API-Kit-requests

但是这里提到的解决方案并不实际适用

在 raml 中,这两个端点都有效。你可以用这个没问题。

我解决了这个问题,只是在 APIkit Router 之前添加了一个 groovy 脚本。

import org.mule.api.transport.PropertyScope

if(message.getInboundProperty('http.request.path') == '/api/items') 
    message.setProperty('http.request.path', '/api/items/*', PropertyScope.INBOUND)`

当我看到星号 * 作为项目 ID 时,我会在流程实施中相应地采取行动