<?php

declare(strict_types=1);

namespace ApiModel\Route;

use ApiModel\Action\MetricsAction;
use ApiModel\Shared\Support\HttpRunner;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Slim\Routing\RouteCollectorProxy;

final class MetricsRoutes
{
    public static function register(RouteCollectorProxy $g, MetricsAction $metricsAction): void
    {
        $g->get('/metrics', fn (ServerRequestInterface $request, ResponseInterface $response) => HttpRunner::runJson($request, $response, fn () => $metricsAction->snapshot($request)));
    }
}
