<?php
declare(strict_types=1);
namespace App\Controller;
use App\Services\Http\RobotsTxtBuilder;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Component\Routing\Annotation\Route;
#[AsController]
final class RobotsTxtController
{
public function __construct(
private readonly RobotsTxtBuilder $robotsTxtBuilder,
) {
}
#[Route(path: '/robots.txt', name: 'robots_txt', methods: ['GET'])]
public function __invoke(): Response
{
return new Response(
$this->robotsTxtBuilder->build(),
Response::HTTP_OK,
[
'Content-Type' => 'text/plain; charset=UTF-8',
'Cache-Control' => 'public, max-age=3600',
],
);
}
}