我想限制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节流阀?