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

Rate Limiting does not work #1517

Open ahmadbadpey opened 6 years ago

ahmadbadpey commented 6 years ago
Q A
Bug? no
New Feature? no
Framework Laravel
Framework version 5.5.32
Package version 2.0.0-alpha1
PHP version 7.x.y

According to this guidance ,I added a throttle functionality to a specific route in my laravel project like this :

$api->group(['prefix' => 'auth'], function ($api) {
    $api->post('checkUser', ['middleware' => 'api.throttle', 'limit' => 3, 'expires' => 20, 'uses' => 'Auth\LoginController@checkUser']);
});

As you can see I added a throttle , limit of 3 with an expiration time of 20 minutes for this specific route.

But even I request that rout more than 3 times, no things occurred.

I do not know what is problem or is need any more step or not?

mayuripansuriya commented 6 years ago

Have you published the package?

from2day commented 6 years ago

Have you tried to define in different structure? Try this from documentation, then you should know if the throttle is set up correctly at least.

$api->version('v1', ['middleware' => 'api.throttle', 'limit' => 3, 'expires' => 20], function ($api) {
    $api->get('users', function () {
        return User::all();
    });
});