4

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,

Paul Carey
  • 516
  • 1
  • 4
  • 15

1 Answers1

6

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.

akond
  • 15,865
  • 4
  • 35
  • 55