<?php
/*
* This file is part of the tmb/go-api package.
*
* (c) 2021 acero <acero@tinizara.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Controller;
use App\DataTransfer\ServiceOptionsInfoDTO;
use Can\RestBundle\Controller\RestController;
use Can\RestBundle\Link\Std\DescribedByLink;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* Service REST Controller.
*
* This class was generated on Mon, 22 Feb 2021 09:36:10 +0100.
*
* @package tmb/go-api
* @author acero <acero@tinizara.org>
*/
class ServiceRestController extends RestController
{
/**
* @Route("/", methods={"OPTIONS"}, name="options_service_collection")
*
* OPTIONS /
*
* @return Response
*/
public function getOptions(): Response
{
$options = new ServiceOptionsInfoDTO();
$response = $this->createResponse(200, $options);
$response->headers->set('Allow', 'GET,POST,DELETE,HEAD,OPTIONS,PUT,PATCH');
$response->headers->set('Link', (string) new DescribedByLink($this->schemaURL()));
return $response;
}
/**
* @Route("/", methods={"GET"}, name="get_service_collection")
*
* GET /
*
* Altough there's actually nothing behind this endpoint, its advisable to
* include a route for GET /, as it's probably that clients accidentally
* (or not) make requests to this endpoint (e.g., ping this endpoint to
* check whether the service is alive).
*
* @return Response
*/
public function getCollection(): Response
{
$response = $this->createResponse(204);
$response->headers->set('Cache-Control', 'public, max-age=31536000, immutable');
return $response;
}
/**
* @Route("/", methods={"HEAD"}, name="head_service_collection")
*
* HEAD /
*
* See comment on GET / endpoint above. Clients may use this endpoint to
* check whether the service is alive.
*
* @return Response
*/
public function headCollection(): Response
{
$response = $this->createResponse(204);
$response->headers->set('Cache-Control', 'public, max-age=31536000, immutable');
return $response;
}
}