mule-restlet 可以将 URL 模式映射到特定方法吗?
将传入的 http 请求转换为 Play! Web 框架中的特定方法非常简单向前,如下所示:
GET /users/{userId} UserController.getUser
POST /users UserController.addUser
PUT /users UserController.updateUser
DELETE /users/{userId} UserController.deleteUser
但我发现在 Mule-Restlet 中很难做到这一点。
<model name="userModel">
<service name="userService">
<inbound>
<inbound-endpoint address="http://localhost:63080"/>
</inbound>
<outbound>
<filtering-router>
<outbound-endpoint address="vm://userController"/>
<or>
<restlet:uri-template-filter pattern="/users/{userId}" verbs="GET"/>
<restlet:uri-template-filter pattern="/users" verbs="POST"/>
<restlet:uri-template-filter pattern="/users" verbs="PUT"/>
<restlet:uri-template-filter pattern="/users/{userId}" verbs="DELETE"/>
</or>
</filtering-router>
</outbound>
</service>
<service name="userController">
<inbound>
<inbound-endpoint address="vm://userController"/>
</inbound>
<!-- **TODO: How to implement UserController** -->
<component class="com.ggd543.mulerestletdemo.user.UserController"/>
</service>
</model>
To translate an incoming http request to the specific method in Play! web framework is straight forward, which look like as follows:
GET /users/{userId} UserController.getUser
POST /users UserController.addUser
PUT /users UserController.updateUser
DELETE /users/{userId} UserController.deleteUser
But I find it hard to do this in Mule-Restlet.
<model name="userModel">
<service name="userService">
<inbound>
<inbound-endpoint address="http://localhost:63080"/>
</inbound>
<outbound>
<filtering-router>
<outbound-endpoint address="vm://userController"/>
<or>
<restlet:uri-template-filter pattern="/users/{userId}" verbs="GET"/>
<restlet:uri-template-filter pattern="/users" verbs="POST"/>
<restlet:uri-template-filter pattern="/users" verbs="PUT"/>
<restlet:uri-template-filter pattern="/users/{userId}" verbs="DELETE"/>
</or>
</filtering-router>
</outbound>
</service>
<service name="userController">
<inbound>
<inbound-endpoint address="vm://userController"/>
</inbound>
<!-- **TODO: How to implement UserController** -->
<component class="com.ggd543.mulerestletdemo.user.UserController"/>
</service>
</model>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据 Restlet Transport 文档,您应该能够将您的路由映射缩短为:
然后要开发您的 UserController 资源,请参阅 Restlet 的用户指南,与传输所使用的版本相关。
According to the Restlet Transport doc, you should be able to shorten your routing map to:
Then to develop your UserController resource, refer to the Restlet's user guide that is relevant to the version in use by the transport.