refacto: Refactor item endpoint

This commit is contained in:
Mangiang 2021-10-12 00:46:13 -04:00
parent 1dc4a5e74d
commit 828f740f4a
2 changed files with 3 additions and 5 deletions

View File

@ -44,10 +44,10 @@ class ItemController extends Controller
* @param string $locale * @param string $locale
* @return JsonResponse * @return JsonResponse
*/ */
public function getItem(string $id, string $locale = 'en'): JsonResponse public function getItem(Request $request): JsonResponse
{ {
try { try {
return response()->json($this->itemsCollection->getItemById($id, $locale)); return response()->json($this->itemsCollection->getItemById($request->id, $request->locale ?? 'en'));
} catch (Throwable $exception) { } catch (Throwable $exception) {
Log::error($exception->getMessage()); Log::error($exception->getMessage());
Log::error($exception->getTraceAsString()); Log::error($exception->getTraceAsString());

View File

@ -20,7 +20,5 @@ $router->get('/', function () {
$router->get('/api/locales', 'ItemController@getLocales'); $router->get('/api/locales', 'ItemController@getLocales');
$router->get('/api/refresh', 'ItemController@refreshAllCache'); $router->get('/api/refresh', 'ItemController@refreshAllCache');
$router->post('/api/search', 'ItemController@search'); $router->post('/api/search', 'ItemController@search');
$router->get('/api/item', 'ItemController@getItem');
$router->get('/api/item/{id}/{locale}', 'ItemController@getItem');
$router->get('/api/item/{id}', 'ItemController@getItem');