开发者

Using Zend_Rest_Route with Zend_Navigation

I want to start using Zend_Rest_Controller for my app, and have set up the routing like so in my bootstrap:

protected function _initRestfulRoutes()
{
    $front = Zend_Controller_Front::getInstance();
    $router = $front->getRouter();

    // Specifying all controllers as RESTful:
    $restRoute = new Zend_Rest_Route($front);
    $router->addRoute('default', $restRoute);
}

However, when using Zend_Navigation, all routes will default to index action. My routes are开发者_如何学运维 defined like so:

    <users>
        <label>Users</label>
        <controller>users</controller>
        <action>index</action>
        <route>default</route>
        <pages>
            <delete>
                <label>Delete Me</label>
                <controller>users</controller>
                <action>delete</action>
                <id>1</id>
                <route>default</route>
            </delete>
        </pages>
    </users>

The delete route resolves as http://myapp.com/users instead of http://myapp.com/users/1?_method=DELETE

Any idea what's going on? Thanks.


Zend_Rest_Route will not route to the "deleteAction()" based on a GET request. In order to invoke "deleteAction", you'll need to send a POST request with _method=DELETE in the body of the request.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜