refacto: Refactor item endpoint
This commit is contained in:
parent
1dc4a5e74d
commit
828f740f4a
@ -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());
|
||||||
|
@ -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');
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user