Commit 45c6aa7a authored by Mat's avatar Mat

vérification d'une première route de l'API/v2 en GET avec postman

parent c964e7da
...@@ -103,7 +103,7 @@ lexik_jwt_authentication: ...@@ -103,7 +103,7 @@ lexik_jwt_authentication:
# Nelmio CORS # Nelmio CORS
nelmio_cors: nelmio_cors:
paths: paths:
'^/api/': '^/API/':
allow_origin: ['*'] allow_origin: ['*']
allow_headers: ['X-Custom-Auth'] allow_headers: ['X-Custom-Auth']
allow_methods: ['POST', 'PUT', 'GET', 'DELETE', 'PATCH'] allow_methods: ['POST', 'PUT', 'GET', 'DELETE', 'PATCH']
...@@ -121,7 +121,7 @@ fos_rest: ...@@ -121,7 +121,7 @@ fos_rest:
enabled: true enabled: true
format_listener: format_listener:
rules: rules:
path: ^/api path: ^/API
priorities: [json] priorities: [json]
fallback_format: 'json' fallback_format: 'json'
view: view:
......
...@@ -29,7 +29,7 @@ security: ...@@ -29,7 +29,7 @@ security:
security: false security: false
main: main:
pattern: ^/ pattern: ^/
anonymous: false anonymous: true
# un anonyme n'aura accès qu'aux pages login et register # un anonyme n'aura accès qu'aux pages login et register
form_login: form_login:
login_path: login login_path: login
......
<?php
namespace Api2Bundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
class DefaultController extends Controller
{
/**
* @Route("/")
*/
public function indexAction()
{
return $this->render('Api2Bundle:Default:index.html.twig');
}
}
<?php
namespace Api2Bundle\Controller;
use FOS\RestBundle\Controller\Annotations as Rest;
use FOS\RestBundle\Controller\FOSRestController;
use SocketBundle\Entity\Message;
class MessageController extends FOSRestController
{
/**
* @Rest\Get("/message")
* @Rest\View()
*/
public function getAction()
{
return $this->getDoctrine()
->getRepository(Message::class)
->findAll();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment