Zend 路由和 HTTP 动词/方法
您好,我正在尝试在 Zend 应用程序中设置一些 REST 路由,我想知道如何限制可以访问路由的 HTTP 方法。
$route = new Zend_Controller_Router_Route('user/reset_password', array(
'module' => 'default',
'controller' => 'user',
'action' => 'resetpassword'
));
$front_controller->getRouter()->addRoute('reset_password', $route);
在此路由中,我想指定该路由将响应的 HTTP 动词,例如 GET、POST、PUT 等,例如添加“method”=> “POST”到数组。
谢谢,
Hi I am trying to setup some REST routes in a Zend app, I am wondering how I can restrict the HTTP method on which the route can be accessed.
$route = new Zend_Controller_Router_Route('user/reset_password', array(
'module' => 'default',
'controller' => 'user',
'action' => 'resetpassword'
));
$front_controller->getRouter()->addRoute('reset_password', $route);
In this route I would like to specify the HTTP verb like GET, POST, PUT, etc that this route will respond to, such as adding "method" => "POST" to the array.
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能在 ZF 的当前实现中执行此操作,因为它将路由接口声明为:
正如您所看到的,没有方法参数的空间。
但是,您可以执行所有检查,例如在控制器中或编写自己的路由器。
You cannot do that in the current implementation of ZF since it declares route interface as:
As you can see there is no room for method parameter.
However, you could do all the checks, say, in the controller or write your own router.