configureRateLimiting(); $this->mapApiRoutes(); $this->mapWpsRoutes(); $this->mapAdminApiRoutes(); $this->routes(function () { Route::middleware('web') ->namespace($this->namespace) ->group(base_path('routes/web.php')); }); } /** * Configure the rate limiters for the application. * * @return void */ protected function configureRateLimiting() { RateLimiter::for('api', function (Request $request) { return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip()); }); } protected function mapApiRoutes() { Route::prefix('api') ->middleware('api') ->namespace($this->namespace) ->group(base_path('routes/api.php')); //dd($this->namespace); foreach ( glob(base_path('routes'.DIRECTORY_SEPARATOR.'api'.DIRECTORY_SEPARATOR).'*.php' ) as $fileName ) { $fileName = basename( $fileName ); Route::middleware('api_verify') ->namespace( $this->namespace."\\Api" ) ->prefix('api') ->group( base_path('routes'.DIRECTORY_SEPARATOR.'api'.DIRECTORY_SEPARATOR."{$fileName}") ); } } /** * Wps回调地址 */ function mapWpsRoutes(){ foreach ( glob(base_path('routes'.DIRECTORY_SEPARATOR.'wps'.DIRECTORY_SEPARATOR).'*.php' ) as $fileName ) { $fileName = basename( $fileName ); Route::namespace( $this->namespace."\\Wps" ) ->prefix('wps') ->group( base_path('routes'.DIRECTORY_SEPARATOR.'wps'.DIRECTORY_SEPARATOR."{$fileName}") ); } } /** * 总后台API路由 */ protected function mapAdminApiRoutes(){ foreach ( glob(base_path('routes'.DIRECTORY_SEPARATOR.'adminApi'.DIRECTORY_SEPARATOR).'*.php' ) as $fileName ) { $fileName = basename( $fileName ); //中间件过滤加载 Route::middleware('adminApiVerify') ->namespace( $this->namespace."\\AdminApi" ) ->prefix('adminApi') ->group( base_path('routes'.DIRECTORY_SEPARATOR.'adminApi'.DIRECTORY_SEPARATOR."{$fileName}") ); } } }