From a0405debef8013b8c28de38d28385adb03fe8526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Leuilliot?= Date: Sat, 13 Jun 2020 12:53:14 +0200 Subject: [PATCH] feat: make routes cachable (#47) --- src/ApiServiceProvider.php | 5 +- src/Http/routes.php | 125 +++++++++++++++++++------------------ 2 files changed, 66 insertions(+), 64 deletions(-) diff --git a/src/ApiServiceProvider.php b/src/ApiServiceProvider.php index 5f869f1..b6634a2 100644 --- a/src/ApiServiceProvider.php +++ b/src/ApiServiceProvider.php @@ -80,8 +80,9 @@ public function apply_custom_configuration() config(['l5-swagger.constants.L5_SWAGGER_CONST_HOST' => sprintf('%s/api', env('APP_URL'))]); // SwaggerUI long description. - config(['l5-swagger.constants.L5_SWAGGER_DESCRIPTION' => 'SeAT API Documentation. ' . - 'All endpoints require an API key. Keys may be obtained from: ' . route('api-admin.list'), ]); + config([ + 'l5-swagger.constants.L5_SWAGGER_DESCRIPTION' => 'SeAT API Documentation. All endpoints require an API key.', + ]); } /** diff --git a/src/Http/routes.php b/src/Http/routes.php index aef52fb..b12adb4 100644 --- a/src/Http/routes.php +++ b/src/Http/routes.php @@ -20,6 +20,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +use Illuminate\Support\Facades\Route; + Route::group([ 'namespace' => 'Seat\Api\Http\Controllers', ], function () { @@ -32,20 +34,19 @@ 'middleware' => ['auth', 'can:global.superuser'], 'prefix' => 'api-admin', ], function () { - - Route::get('/', [ - 'as' => 'api-admin.list', - 'uses' => 'ApiAdminController@listTokens', ]); - Route::post('/', [ - 'as' => 'api-admin.token.create', - 'uses' => 'ApiAdminController@generateToken', ]); - Route::get('/logs/{token_id}', [ - 'as' => 'api-admin.token.logs', - 'uses' => 'ApiAdminController@show', ]); - Route::get('/delete/{token_id}', [ - 'as' => 'api-admin.token.delete', - 'uses' => 'ApiAdminController@deleteToken', ]); - + Route::get('/') + ->name('api-admin.list') + ->uses('ApiAdminController@listTokens'); + + Route::post('/') + ->name('api-admin.token.create') + ->uses('ApiAdminController@generateToken'); + Route::get('/logs/{token_id}') + ->name('api-admin.token.logs') + ->uses('ApiAdminController@show'); + Route::get('/delete/{token_id}') + ->name('api-admin.token.delete') + ->uses('ApiAdminController@deleteToken'); }); }); @@ -61,79 +62,79 @@ Route::group(['prefix' => 'users'], function () { - Route::post('/', 'UserController@postNewUser'); - Route::delete('/{user_id}', 'UserController@deleteUser'); + Route::post('/')->uses('UserController@postNewUser'); + Route::delete('/{user_id}')->uses('UserController@deleteUser'); - Route::get('/', 'UserController@getUsers'); - Route::get('/{user_id}', 'UserController@show')->where(['user_id' => '[0-9]+']); + Route::get('/')->uses('UserController@getUsers'); + Route::get('/{user_id}')->uses('UserController@show')->where(['user_id' => '[0-9]+']); - Route::get('/configured-scopes', 'UserController@getConfiguredScopes'); + Route::get('/configured-scopes')->uses('UserController@getConfiguredScopes'); }); Route::group(['prefix' => 'squads'], function () { - Route::get('/', 'SquadController@index'); - Route::get('/{squad_id}', 'SquadController@show'); - Route::post('/', 'SquadController@store'); - Route::put('/{squad_id}', 'SquadController@update'); - Route::delete('/{squad_id}', 'SquadController@destroy'); + Route::get('/')->uses('SquadController@index'); + Route::get('/{squad_id}')->uses('SquadController@show'); + Route::post('/')->uses('SquadController@store'); + Route::put('/{squad_id}')->uses('SquadController@update'); + Route::delete('/{squad_id}')->uses('SquadController@destroy'); }); Route::group(['prefix' => 'roles'], function () { - Route::get('/', 'RoleController@getIndex'); - Route::get('/{role_id}', 'RoleController@getDetail')->where('role_id', '[0-9]+'); - Route::post('/', 'RoleController@postNew'); - Route::patch('/{role_id}', 'RoleController@patch')->where('role_id', '[0-9]+'); - Route::delete('/{role_id}', 'RoleController@deleteRole')->where('role_id', '[0-9]+'); - Route::post('/members', 'RoleController@postGrantUserRole'); - Route::delete('/members/{user_id}/{role_id}', 'RoleController@deleteRevokeUserRole'); + Route::get('/')->uses('RoleController@getIndex'); + Route::get('/{role_id}')->uses('RoleController@getDetail')->where('role_id', '[0-9]+'); + Route::post('/')->uses('RoleController@postNew'); + Route::patch('/{role_id}')->uses('RoleController@patch')->where('role_id', '[0-9]+'); + Route::delete('/{role_id}')->uses('RoleController@deleteRole')->where('role_id', '[0-9]+'); + Route::post('/members')->uses('RoleController@postGrantUserRole'); + Route::delete('/members/{user_id}/{role_id}')->uses('RoleController@deleteRevokeUserRole'); Route::group(['prefix' => 'query'], function () { - Route::get('/permissions', 'RoleLookupController@getPermissions'); - Route::get('/role-check/{character_id}/{role_name}', 'RoleLookupController@getRoleCheck'); - Route::get('/permission-check/{character_id}/{permission_name}', 'RoleLookupController@getPermissionCheck'); + Route::get('/permissions')->uses('RoleLookupController@getPermissions'); + Route::get('/role-check/{character_id}/{role_name}')->uses('RoleLookupController@getRoleCheck'); + Route::get('/permission-check/{character_id}/{permission_name}')->uses('RoleLookupController@getPermissionCheck'); }); }); Route::group(['prefix' => 'killmails'], function () { - Route::get('/{killmail_id}', 'KillmailsController@getDetail'); + Route::get('/{killmail_id}')->uses('KillmailsController@getDetail'); }); Route::group(['prefix' => 'character'], function () { - Route::get('/assets/{character_id}/{item_id?}', 'CharacterController@getAssets'); - Route::get('/bookmarks/{character_id}', 'CharacterController@getBookmarks'); - Route::get('/contacts/{character_id}', 'CharacterController@getContacts'); - Route::get('/industry/{character_id}', 'CharacterController@getIndustry'); - Route::get('/killmails/{character_id}/{killmail_id?}', 'KillmailsController@getCharacterKillmails'); - Route::get('/market-orders/{character_id}', 'CharacterController@getMarketOrders'); - Route::get('/contracts/{character_id}', 'CharacterController@getContracts'); - Route::get('/sheet/{character_id}', 'CharacterController@getSheet'); - Route::get('/skills/{character_id}', 'CharacterController@getSkills'); - Route::get('/skill-queue/{character_id}', 'CharacterController@getSkillQueue'); - Route::get('/wallet-journal/{character_id}', 'CharacterController@getWalletJournal'); - Route::get('/wallet-transactions/{character_id}', 'CharacterController@getWalletTransactions'); - Route::get('/corporation-history/{character_id}', 'CharacterController@getCorporationHistory'); - Route::get('/jump-clones/{character_id}', 'CharacterController@getJumpClones'); - Route::get('/mail/{character_id}', 'CharacterController@getMail'); - Route::get('/notifications/{character_id}', 'CharacterController@getNotifications'); + Route::get('/assets/{character_id}/{item_id?}')->uses('CharacterController@getAssets'); + Route::get('/bookmarks/{character_id}')->uses('CharacterController@getBookmarks'); + Route::get('/contacts/{character_id}')->uses('CharacterController@getContacts'); + Route::get('/industry/{character_id}')->uses('CharacterController@getIndustry'); + Route::get('/killmails/{character_id}/{killmail_id?}')->uses('KillmailsController@getCharacterKillmails'); + Route::get('/market-orders/{character_id}')->uses('CharacterController@getMarketOrders'); + Route::get('/contracts/{character_id}')->uses('CharacterController@getContracts'); + Route::get('/sheet/{character_id}')->uses('CharacterController@getSheet'); + Route::get('/skills/{character_id}')->uses('CharacterController@getSkills'); + Route::get('/skill-queue/{character_id}')->uses('CharacterController@getSkillQueue'); + Route::get('/wallet-journal/{character_id}')->uses('CharacterController@getWalletJournal'); + Route::get('/wallet-transactions/{character_id}')->uses('CharacterController@getWalletTransactions'); + Route::get('/corporation-history/{character_id}')->uses('CharacterController@getCorporationHistory'); + Route::get('/jump-clones/{character_id}')->uses('CharacterController@getJumpClones'); + Route::get('/mail/{character_id}')->uses('CharacterController@getMail'); + Route::get('/notifications/{character_id}')->uses('CharacterController@getNotifications'); }); Route::group(['prefix' => 'corporation'], function () { - Route::get('/assets/{corporation_id}', 'CorporationController@getAssets'); - Route::get('/bookmarks/{corporation_id}', 'CorporationController@getBookmarks'); - Route::get('/contacts/{corporation_id}', 'CorporationController@getContacts'); - Route::get('/contracts/{corporation_id}', 'CorporationController@getContracts'); - Route::get('/industry/{corporation_id}', 'CorporationController@getIndustry'); - Route::get('/killmails/{corporation_id}', 'KillmailsController@getCorporationKillmails'); - Route::get('/market-orders/{corporation_id}', 'CorporationController@getMarketOrders'); - Route::get('/member-tracking/{corporation_id}', 'CorporationController@getMemberTracking'); - Route::get('/sheet/{corporation_id}', 'CorporationController@getSheet'); - Route::get('/wallet-journal/{corporation_id}', 'CorporationController@getWalletJournal'); - Route::get('/wallet-transactions/{corporation_id}', 'CorporationController@getWalletTransactions'); + Route::get('/assets/{corporation_id}')->uses('CorporationController@getAssets'); + Route::get('/bookmarks/{corporation_id}')->uses('CorporationController@getBookmarks'); + Route::get('/contacts/{corporation_id}')->uses('CorporationController@getContacts'); + Route::get('/contracts/{corporation_id}')->uses('CorporationController@getContracts'); + Route::get('/industry/{corporation_id}')->uses('CorporationController@getIndustry'); + Route::get('/killmails/{corporation_id}')->uses('KillmailsController@getCorporationKillmails'); + Route::get('/market-orders/{corporation_id}')->uses('CorporationController@getMarketOrders'); + Route::get('/member-tracking/{corporation_id}')->uses('CorporationController@getMemberTracking'); + Route::get('/sheet/{corporation_id}')->uses('CorporationController@getSheet'); + Route::get('/wallet-journal/{corporation_id}')->uses('CorporationController@getWalletJournal'); + Route::get('/wallet-transactions/{corporation_id}')->uses('CorporationController@getWalletTransactions'); }); });