update: server etag

This commit is contained in:
tokumeikoi 2022-11-25 03:53:18 +08:00
parent 56a6025ef9
commit 2930f1957c
3 changed files with 9 additions and 3 deletions

View File

@ -26,8 +26,14 @@ class ServerController extends Controller
$serverService = new ServerService(); $serverService = new ServerService();
$servers = $serverService->getAvailableServers($user); $servers = $serverService->getAvailableServers($user);
} }
$eTag = sha1(json_encode(array_column($servers, 'updated_at')));
if (strpos($request->header('If-None-Match'), $eTag) !== false ) {
abort(304);
}
return response([ return response([
'data' => $servers 'data' => $servers
]); ])->header('ETag', "\"{$eTag}\"");
} }
} }

View File

@ -113,7 +113,8 @@ class UserController extends Controller
'u', 'u',
'd', 'd',
'transfer_enable', 'transfer_enable',
'email' 'email',
'uuid'
]) ])
->first(); ->first();
if (!$user) { if (!$user) {

View File

@ -14,7 +14,6 @@ class ClientRoute
// Client // Client
$router->get('/subscribe', 'Client\\ClientController@subscribe'); $router->get('/subscribe', 'Client\\ClientController@subscribe');
// App // App
$router->get('/app/config', 'Client\\AppController@config');
$router->get('/app/getConfig', 'Client\\AppController@getConfig'); $router->get('/app/getConfig', 'Client\\AppController@getConfig');
$router->get('/app/getVersion', 'Client\\AppController@getVersion'); $router->get('/app/getVersion', 'Client\\AppController@getVersion');
}); });