<?php

namespace apexl\Io\modules\system\controllers;

use apexl\Io\includes\Controller;
use apexl\Io\modules\system\services\RouteDebugHelper;
use JsonException;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

final readonly class GetRoutesController extends Controller
{
    /**
     * Get all available routes and information attached to them, return as a structured array for JSON response.
     * @method GET
     * @throws JsonException
     */
    public function __invoke(
        RouteDebugHelper $routeDebugHelper,
        ServerRequestInterface $request,
        ResponseInterface $response
    ): ResponseInterface {
        return $this->json($response, $routeDebugHelper->routes());
    }
}
