- Création API recherche

This commit is contained in:
2025-01-29 10:15:16 +01:00
parent 3797ef0582
commit f2dd1047a1
6 changed files with 249 additions and 1 deletions

View File

@ -0,0 +1,25 @@
<?php
namespace App\Controller;
use App\Service\GoogleBooksService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
class APITestController extends AbstractController
{
private GoogleBooksService $googleBooksService;
public function __construct(GoogleBooksService $googleBooksService)
{
$this->googleBooksService = $googleBooksService;
}
#[Route('/api/search', name: 'api_search')]
public function search(): JsonResponse
{
$results = $this->googleBooksService->searchBooks('Le loup des steppes');
return $this->json($results);
}
}