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_R开发者_开发百科outer_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,
You cannot do that in the current implementation of ZF since it declares route interface as:
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);
}
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.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论