应用接口服务限流工具,简单实现令牌桶
v1.0.1 版本
2022-04-06 版本更新时间
870 安装
16 star
简介
限流类
- 全局中间件,整个应用接口限流,
- 路由中间件,某些功能接口请求速率限制
缓存依据的是Support\Cache的 instance(), 其他类只要是实现 get($key, $default = null), set($key, $value, $ttl = null), delete($key) funtion就行.
安装
composer require nsp-team/webman-throttler
使用
默认 开启全局中间件限流
return [ '' => [ \NspTeam\WebmanThrottler\Middleware\ThrottlerMiddleware::class, ] ]; 你也可以启用路由中间件,控制接口请求速率限制
例如:
Route::group('/sys/user', static function () { Route::post('/test', [User::class, 'test']); })->middleware([ \NspTeam\WebmanThrottler\Middleware\ThrottlerMiddleware::class ]); 效果图(可选)

