src/Controller/ServiceRestController.php line 63

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the tmb/go-api package.
  4.  * 
  5.  * (c) 2021 acero <acero@tinizara.org>
  6.  * 
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace App\Controller;
  11. use App\DataTransfer\ServiceOptionsInfoDTO;
  12. use Can\RestBundle\Controller\RestController;
  13. use Can\RestBundle\Link\Std\DescribedByLink;
  14. use Symfony\Component\HttpFoundation\Response;
  15. use Symfony\Component\Routing\Annotation\Route;
  16. /**
  17.  * Service REST Controller.
  18.  *
  19.  * This class was generated on Mon, 22 Feb 2021 09:36:10 +0100.
  20.  *
  21.  * @package tmb/go-api
  22.  * @author acero <acero@tinizara.org>
  23.  */
  24. class ServiceRestController extends RestController
  25. {
  26.     /**
  27.      * @Route("/", methods={"OPTIONS"}, name="options_service_collection")
  28.      *
  29.      * OPTIONS /
  30.      *
  31.      * @return Response
  32.      */
  33.     public function getOptions(): Response
  34.     {
  35.         $options = new ServiceOptionsInfoDTO();
  36.         $response $this->createResponse(200$options);
  37.         $response->headers->set('Allow''GET,POST,DELETE,HEAD,OPTIONS,PUT,PATCH');
  38.         $response->headers->set('Link', (string) new DescribedByLink($this->schemaURL()));
  39.         return $response;
  40.     }
  41.     /**
  42.      * @Route("/", methods={"GET"}, name="get_service_collection")
  43.      *
  44.      * GET /
  45.      *
  46.      * Altough there's actually nothing behind this endpoint, its advisable to
  47.      * include a route for GET /, as it's probably that clients accidentally
  48.      * (or not) make requests to this endpoint (e.g., ping this endpoint to
  49.      * check whether the service is alive).
  50.      *
  51.      * @return Response
  52.      */
  53.     public function getCollection(): Response
  54.     {
  55.         $response $this->createResponse(204);
  56.         $response->headers->set('Cache-Control''public, max-age=31536000, immutable');
  57.         return $response;
  58.     }
  59.     /**
  60.      * @Route("/", methods={"HEAD"}, name="head_service_collection")
  61.      *
  62.      * HEAD /
  63.      *
  64.      * See comment on GET / endpoint above. Clients may use this endpoint to
  65.      * check whether the service is alive.
  66.      *
  67.      * @return Response
  68.      */
  69.     public function headCollection(): Response
  70.     {
  71.         $response $this->createResponse(204);
  72.         $response->headers->set('Cache-Control''public, max-age=31536000, immutable');
  73.         return $response;
  74.     }
  75. }