问题描述
|
嗨,我正在尝试在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 \”。
谢谢,
解决方法
在ZF的当前实现中,您无法执行此操作,因为ZF将route接口声明为:
interface Zend_Controller_Router_Route_Interface {
public function match($path);
public function assemble($data = array(),$reset = false,$encode = false);
public static function getInstance(Zend_Config $config);
}
如您所见,方法参数没有空间。
但是,您可以在控制器中进行所有检查,也可以编写自己的路由器。