Open aleemb opened 8 years ago
At the same time would also be nice to have the limit
and expires
globally definable in the api config.
Also possibly related, this results in an error:
$api->get('user', ['middleware' => 'api.throttle', 'limit' => 30, 'expires' => 1, 'uses' => 'UsersController@show']);
{"message":"Unsupported operand types","code":1,"status_code":500,"debug":{"line":125,"file":"\/var\/www\/app\/vendor\/dingo\/api\/src\/Http\/RateLimit\/Handler.php","class":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","trace":["#0 {main}"]}}
+1
Yeah probably a nicer way of doing it. Will need to look at some possible compatibility issues but I'm all for getting this changed. Will keep you posted.
Laravel 5.2 already has throttling though I prefer the Dingo API's throttling due to some additional features. However, the new middleware groups would be benefit from having the throttling defined directly in the middleware string ala
api.throttle:30,1
instead of passing additional values, so that the middleware group array can leverage it as here https://github.com/laravel/laravel/blob/master/app/Http/Kernel.php#L35