dingo / api

A RESTful API package for the Laravel and Lumen frameworks.
BSD 3-Clause "New" or "Revised" License
9.33k stars 1.25k forks source link

Throttling args #1021

Open aleemb opened 8 years ago

aleemb commented 8 years ago

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

aleemb commented 8 years ago

At the same time would also be nice to have the limit and expires globally definable in the api config.

aleemb commented 8 years ago

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}"]}}
Luddinus commented 8 years ago

+1

jasonlewis commented 8 years ago

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.