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条)

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?