Pau*_*rey 4 rest zend-framework routes http zend-route
嗨我想在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);
Run Code Online (Sandbox Code Playgroud)
在这条路线中,我想指定此路由将响应的HTTP动词,如GET,POST,PUT等,例如向数组添加"method"=>"POST".
谢谢,
您不能在ZF的当前实现中执行此操作,因为它将路由接口声明为:
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);
}
Run Code Online (Sandbox Code Playgroud)
如您所见,方法参数没有空间.
但是,您可以在控制器中执行所有检查,也可以编写自己的路由器.