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();
$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([
'data' => $servers
]);
])->header('ETag', "\"{$eTag}\"");
}
}

View File

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

View File

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