perf: 优化openapi接口频率限制
This commit is contained in:
@@ -31,7 +31,11 @@ Route::group('v1', function() {
|
|||||||
->middleware(\app\openapi\middleware\Auth::class);
|
->middleware(\app\openapi\middleware\Auth::class);
|
||||||
})
|
})
|
||||||
->middleware(\think\middleware\Throttle::class, [
|
->middleware(\think\middleware\Throttle::class, [
|
||||||
'visit_rate' => '5/m',
|
'prefix' => 'throttle_',
|
||||||
|
'visit_rate' => '5/m',
|
||||||
|
'key' => function($throttle, $request) {
|
||||||
|
return '__CONTROLLER__/__ACTION__/__IP__';
|
||||||
|
},
|
||||||
'visit_fail_response' => function (\think\middleware\Throttle $throttle, \think\Request $request, int $wait_seconds) {
|
'visit_fail_response' => function (\think\middleware\Throttle $throttle, \think\Request $request, int $wait_seconds) {
|
||||||
return \think\Response::create('您的操作过于频繁, 请在 ' . $wait_seconds . ' 秒后再试。')->code(429);
|
return \think\Response::create('您的操作过于频繁, 请在 ' . $wait_seconds . ' 秒后再试。')->code(429);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user