1

I'm trying to make a Zend_Rest_Route for a specific controller. I want the rest of my site to behave normally, except when a particular Controller (UploadAPI) is requested. I think the sytnax should be as follow, but having a hard time verifying. The examples all have to do with modules, but I don't have a module. Is this correct?

protected function _initRestRoute() {
    $this->bootstrap('frontController');
    $frontController = Zend_Controller_Front::getInstance();
    $restRoute = new Zend_Rest_Route($frontController, array(), array('default' => array('UploadAPI'),));
     $frontController->getRouter()->addRoute('rest', $restRoute);
}

The link here

http://weierophinney.net/matthew/archives/228-Building-RESTful-Services-with-Zend-Framework.html

gives examples with modules, but I have no modules, and am assuming "default" is the module name.

hogsolo
  • 13,565
  • 6
  • 24
  • 25

1 Answers1

4

So I have the API functionality working , this is how it looks. You have to add this function in Bootstrap class to initilize Zend_Rest_Route. This will do the Zend Rest API routing only for the controllers listed in the array, the rest of the site should work as expected

protected function _initRestRoute() {
  $this->bootstrap('frontController');
  $frontController = Zend_Controller_Front::getInstance();
  $restRouteUL = new Zend_Rest_Route($frontController, array(), array('default' => array('UploadAPI', 'LocationMatchesAPI', 'GetMatchesByIdAPI', 'AuthAPIController')  ));
$frontController->getRouter()->addRoute('rest', $restRouteUL);
}
hogsolo
  • 13,565
  • 6
  • 24
  • 25