Zend_Rest_Route 用于特定控制器

发布于 2024-11-18 06:50:02 字数 763 浏览 4 评论 0原文

我正在尝试为特定控制器制作 Zend_Rest_Route 。我希望网站的其余部分能够正常运行,除非请求特定控制器 (UploadAPI)。我认为语法应该如下,但很难验证。这些示例都与模块有关,但我没有模块。 这是正确的吗?

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);
}

此处的链接

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

给出了带有模块的示例,但我没有模块,并且假设“default”是模块名称。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

安稳善良 2024-11-25 06:50:02

这样我就可以使用 API 功能了,这就是它的样子。您必须在 Bootstrap 类中添加此函数来初始化 Zend_Rest_Route。
这将仅对数组中列出的控制器进行 Zend Rest API 路由,站点的其余部分应该按预期工作

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);
}

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);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文