Zend_Rest_Route 用于特定控制器
我正在尝试为特定控制器制作 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这样我就可以使用 API 功能了,这就是它的样子。您必须在 Bootstrap 类中添加此函数来初始化 Zend_Rest_Route。
这将仅对数组中列出的控制器进行 Zend Rest API 路由,站点的其余部分应该按预期工作
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