php - Rate Limiting Feature for particular Route in Laravel 5.2 -


i using below code implements rate limiting feature routes in group.

route::group(['middleware' => ['web', 'throttle:2']], function () {     route::get('/csr', array('uses' =>  'csr_controller@index', 'as' => 'csrlist'));     //second route     //third route     //fourth route     //fifth route     //.... }); 

question works great. there way implement particular route in group ?

of course can. attribute can assign route group can assigned single route (in fact route groups apply attributes sequentially each of routes contained within them, nothing more). can assign middleware group such api single route:

route::get('/route/path', ['middleware' => 'api', 'uses' => 'controller@action']); 

or if want use throttling middleware can use:

route::get('/route/path', ['middleware' => 'throttle:2', 'uses' => 'controller@action']); 

for more details on rate limiting feature can check out laracasts video linked below:

what's new in laravel 5.2: api rate limiting


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -