基于User的Dingo Api节流

时间:2019-04-04 14:14:56

标签: laravel-5 dingo-api

我想限制Laravel Application中特定于用户的API请求。 我尝试按照以下代码创建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.
    }
}

我尝试添加以下代码:

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

在Kernel.php的中间件中。但是IDE抛出错误,指出Expressions not allowed

如何使用Dingo在Laravel中基于用户创建API节流阀?

0 个答案:

没有答案