mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-03-30 09:56:05 +02:00
Add versioning to Laravel routes
This commit is contained in:
parent
9ca9fcc9ef
commit
0383f07ad7
@ -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,
|
||||
|
@ -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';
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user