configureRateLimiting(); // 注册将用于加载应用程序路由的回调。 $this->routes(function () { // api路由 Route::prefix('api') ->middleware('api') ->namespace($this->namespace) ->group(base_path('routes/api.php')); // web路由 Route::middleware('web') ->namespace($this->namespace) ->group(base_path('routes/web.php')); }); } /** * 为应用程序配置速率限制器 * * @return void */ protected function configureRateLimiting() { RateLimiter::for('api', function (Request $request) { return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip()); }); } }