|
@@ -35,13 +35,13 @@ class RouteServiceProvider extends ServiceProvider
|
|
|
*/
|
|
|
public function boot()
|
|
|
{
|
|
|
- $this->configureRateLimiting();
|
|
|
+
|
|
|
+
|
|
|
+ $this->mapAdminApiRoutes();
|
|
|
+
|
|
|
+ $this->mapApiRoutes();
|
|
|
|
|
|
$this->routes(function () {
|
|
|
- Route::prefix('api')
|
|
|
- ->middleware('api')
|
|
|
- ->namespace($this->namespace)
|
|
|
- ->group(base_path('routes/api.php'));
|
|
|
|
|
|
Route::middleware('web')
|
|
|
->namespace($this->namespace)
|
|
@@ -60,4 +60,43 @@ class RouteServiceProvider extends ServiceProvider
|
|
|
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ * 总后台API路由
|
|
|
+ */
|
|
|
+ protected function mapAdminApiRoutes(){
|
|
|
+ foreach ( glob(base_path('routes'.DIRECTORY_SEPARATOR.'adminApi'.DIRECTORY_SEPARATOR).'*.php' ) as $fileName ) {
|
|
|
+ $fileName = basename( $fileName );
|
|
|
+ $prefix = substr( $fileName,0,strrpos($fileName,'.') );
|
|
|
+ $nameSpace = ucfirst($prefix);
|
|
|
+
|
|
|
+
|
|
|
+ Route::middleware('adminApi_verify')
|
|
|
+ ->namespace( $this->namespace."\\AdminApi" )
|
|
|
+ ->group( base_path('routes'.DIRECTORY_SEPARATOR.'adminApi'.DIRECTORY_SEPARATOR."{$fileName}") );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * Define the "api" routes for the application.
|
|
|
+ *
|
|
|
+ * These routes are typically stateless.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ protected function mapApiRoutes()
|
|
|
+ {
|
|
|
+ Route::prefix('api')
|
|
|
+ ->middleware('api')
|
|
|
+ ->namespace($this->namespace)
|
|
|
+ ->group(base_path('routes/api.php'));
|
|
|
+
|
|
|
+ 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}") );
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|