CodeIgniter RESTful API速率限制问题 [英] CodeIgniter RESTful API rate limiting issue
问题描述
我正在使用由Phil Sturgeon撰写的以下代码: https://github.com/philsturgeon / codeigniter-restserver
I am working with the following code written by Phil Sturgeon here: https://github.com/philsturgeon/codeigniter-restserver
没有在他的文档中,我可以看到如何在控制器侧设置限制选项。
No where in his docs can I see how the limit option is setup in side of the controller.
RESTController控制器文件有一些引用,例如
the RESTController controller file has some references e.g.
显示受保护的函数,另外还有:
Shows the protected function, additionally there is:
// How many times can you get to this method an hour?
$limit = $this->methods[$controller_method]['limit'];
从rest.php配置:
And from the rest.php config:
/ *
| ---------------------------------- ---------------------------------------- | REST启用限制
| ------------------------------------------ -------------------------------- | |当设置为true时,REST_Controller将计算
每个方法的使用次数|通过API密钥每小时。这是一个一般规则,
可以在|中重写$ this->方法数组在每个控制器。 |
/* |-------------------------------------------------------------------------- | 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. |
任何人都可以帮我解决这个问题吗?现在拉我的头发: - )
Can anyone help me with this please? Pulling my hair out currently :-)
我现在的控制器方法之一:
One of my controllers methods as it currently stands:
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),
);
这篇关于CodeIgniter RESTful API速率限制问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!