duanmangxie7131 2012-11-06 13:27
浏览 68
已采纳

CodeIgniter RESTful API速率限制问题

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.

the RESTController controller file has some references e.g.

Line 654: https://github.com/philsturgeon/codeigniter-restserver/blob/master/application/libraries/REST_Controller.php

Shows the protected function, additionally there is:

 // How many times can you get to this method an hour?
 $limit = $this->methods[$controller_method]['limit'];

And from the rest.php config:

/* |-------------------------------------------------------------------------- | 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);
    }
}
  • 写回答

2条回答 默认 最新

  • douqi2804 2012-11-06 14:19
    关注

    Fixed with:

        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),
        );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog