我正在使用 Phil Sturgeon 编写的以下代码:https://github.com/philsturgeon/codeigniter-restserver
在他的文档中,我没有看到如何在 Controller 一侧设置限制选项。
RESTController Controller 文件有一些引用,例如
显示 protected 函数,另外还有:
// How many times can you get to this method an hour?
$limit = $this->methods[$controller_method]['limit'];
从rest.php配置中:
/* |-------------------------------------------------------------------------- | REST Enable Limits |-------------------------------------------------------------------------- | | When set to true REST_Controller will count the number of uses of each method | by an API key each hour. This is a general rule that can be overridden in the | $this->method array in each controller. |
有人可以帮我解决这个问题吗?目前正在拔我的头发:-)
我目前的 Controller 方法之一:
function listservices_get()
{
$organisation_id = $this->get('id');
$organisations = $this->api_buyus_model->list_services($organisation_id);
if($organisations)
{
$this->response($organisations, 200);
}
else
{
$this->response(array('error' => '1', 'errorDesc' => 'Buy us services list could not be retrieved.'), 400);
}
}
最佳答案
修复:
protected $methods = array(
'index_put' => array('level' => 10, 'limit' => 10),
'index_delete' => array('level' => 10),
'level_post' => array('level' => 10),
'regenerate_post' => array('level' => 10),
);
关于php - CodeIgniter RESTful API 速率限制问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13252050/