diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 9269fc96..e61fc6c0 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -41,7 +41,7 @@ class Kernel extends HttpKernel \App\Http\Middleware\CustomCreateFreshApiToken::class, ], - 'api' => [ + 'api.v1' => [ 'throttle:60,1', 'bindings', \App\Http\Middleware\LogoutInactiveUser::class, diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 820f36c0..7c2b2bde 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -35,11 +35,11 @@ public function boot() */ public function map() { - $this->mapApiRoutes(); - $this->mapWebRoutes(); - // + $this->mapApiVersionOneRoutes(); + + // $this->mapApiVersionTwoRoutes(); } /** @@ -57,17 +57,42 @@ protected function mapWebRoutes() } /** - * Define the "api" routes for the application. + * Define the "v1 api" routes for the application. * * These routes are typically stateless. * * @return void */ - protected function mapApiRoutes() + protected function mapApiVersionOneRoutes() { - Route::prefix('api') - ->middleware('api') - ->namespace($this->namespace) - ->group(base_path('routes/api.php')); + Route::prefix('api/v1') + ->middleware('api.v1') + ->namespace($this->getApiNamespace(1)) + ->group(base_path('routes/api/v1.php')); + } + + /** + * Define the "v2 api" routes for the application. + * + * These routes are typically stateless. + * + * @return void + */ + // protected function mapApiVersionTwoRoutes() + // { + // Route::prefix('api/v2') + // ->middleware('api.v2') + // ->namespace($this->getApiNamespace(2)) + // ->group(base_path('routes/api/v2.php')); + // } + + /** + * Build Api namespace based on provided version + * + * @return string The Api namespace + */ + private function getApiNamespace($version) + { + return 'App\Api\v' . $version . '\Controllers'; } } diff --git a/routes/api.php b/routes/api/v1.php similarity index 100% rename from routes/api.php rename to routes/api/v1.php