File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 420420 PRIMARY KEY (`id`)
421421 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
422422|
423+ | To specify limits, within your Controller __construct() method add per-method
424+ | limits with:
425+
426+ $this->method['METHOD_NAME']['limit'] = [NUM_REQUESTS_PER_HOUR];
427+
428+ | See application/controllers/api/example.php for examples.
423429*/
424430$ config ['rest_enable_limits ' ] = FALSE ;
425431
Original file line number Diff line number Diff line change 1818
1919class Example extends REST_Controller
2020{
21- function user_get ()
21+ function __construct ()
22+ {
23+ // Construct our parent class
24+ parent ::__construct ();
25+
26+ // Configure limits on our controller methods. Ensure
27+ // you have created the 'limits' table and enabled 'limits'
28+ // within application/config/rest.php
29+ $ this ->methods ['user_get ' ]['limit ' ] = 500 ; //500 requests per hour per user/key
30+ $ this ->methods ['user_post ' ]['limit ' ] = 100 ; //100 requests per hour per user/key
31+ $ this ->methods ['user_delete ' ]['limit ' ] = 50 ; //50 requests per hour per user/key
32+ }
33+
34+ function user_get ()
2235 {
2336 if (!$ this ->get ('id ' ))
2437 {
You can’t perform that action at this time.
0 commit comments