mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-06-02 16:25:36 +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,
|
\App\Http\Middleware\CustomCreateFreshApiToken::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
'api' => [
|
'api.v1' => [
|
||||||
'throttle:60,1',
|
'throttle:60,1',
|
||||||
'bindings',
|
'bindings',
|
||||||
\App\Http\Middleware\LogoutInactiveUser::class,
|
\App\Http\Middleware\LogoutInactiveUser::class,
|
||||||
|
@ -35,11 +35,11 @@ class RouteServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function map()
|
public function map()
|
||||||
{
|
{
|
||||||
$this->mapApiRoutes();
|
|
||||||
|
|
||||||
$this->mapWebRoutes();
|
$this->mapWebRoutes();
|
||||||
|
|
||||||
//
|
$this->mapApiVersionOneRoutes();
|
||||||
|
|
||||||
|
// $this->mapApiVersionTwoRoutes();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,17 +57,42 @@ class RouteServiceProvider extends ServiceProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define the "api" routes for the application.
|
* Define the "v1 api" routes for the application.
|
||||||
*
|
*
|
||||||
* These routes are typically stateless.
|
* These routes are typically stateless.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function mapApiRoutes()
|
protected function mapApiVersionOneRoutes()
|
||||||
{
|
{
|
||||||
Route::prefix('api')
|
Route::prefix('api/v1')
|
||||||
->middleware('api')
|
->middleware('api.v1')
|
||||||
->namespace($this->namespace)
|
->namespace($this->getApiNamespace(1))
|
||||||
->group(base_path('routes/api.php'));
|
->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…
x
Reference in New Issue
Block a user