Dingo Api throttling based on User

257 Views Asked by At

I wanted to limit the API request specific to user in Laravel Application. I tried to following code to create custom throttle mentioned in https://github.com/dingo/api/wiki/Rate-Limiting#custom-throttles

use Illuminate\Container\Container;
use Dingo\Api\Http\RateLimit\Throttle\Throttle;

class CustomThrottle extends Throttle
{
    public function match(Container $app)
    {
        // Perform some logic here and return either true or false depending on whether
        // your conditions matched for the throttle.
    }
}

I tried to add this code:

'throttling' => [
    'custom' => new CustomThrottle(['limit' => 200, 'expires' => 10])
]

in Middleware in Kernel.php. But the IDE is throwing error stating Expressions not allowed

How can I create API throttle based on user in Laravel using Dingo?

0

There are 0 best solutions below