mule-restlet可以将URL模式映射到特定方法吗?

时间:2011-12-16 12:59:23

标签: playframework restlet mule

将传入的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>

1 个答案:

答案 0 :(得分:1)

根据Restlet Transport doc,您应该可以将路线图缩短为:

<or-filter>
    <restlet:uri-template-filter pattern="/users" verbs="POST PUT"/>
    <restlet:uri-template-filter pattern="/users/{userId}" verbs="GET DELETE"/>
</or-filter>

然后要开发UserController资源,请参阅与传输使用的版本相关的Restlet's user guide