Added API handler for getting a benchmark's info

This commit is contained in:
Gregory Ballantine 2024-06-03 12:37:13 -04:00
parent 94794f2ca1
commit b9b881ec0c
2 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,22 @@
<?php
namespace BitGoblin\Colossus\Controllers;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Routing\RouteContext;
use BitGoblin\Colossus\Models\Test;
class ApiController extends Controller {
public function getBenchmark(Request $request, Response $response, array $args): Response {
$benchmark = Benchmark::where('id', $args['benchmark_id'])->first();
$payload = json_encode($benchmark);
$response->getBody()->write($payload);
return $response
->withHeader('Content-Type', 'application/json');
}
}

View File

@ -34,3 +34,7 @@ $app->group('/result', function(RouteCollectorProxy $group) {
$app->group('/reports', function(RouteCollectorProxy $group) { $app->group('/reports', function(RouteCollectorProxy $group) {
$group->get('/generate', '\\BitGoblin\\Colossus\Controllers\ReportController:getGenerate')->setName('reports.generate'); $group->get('/generate', '\\BitGoblin\\Colossus\Controllers\ReportController:getGenerate')->setName('reports.generate');
}); });
$app->group('/api', function(RouteCollectorProxy $group) {
$group->get('/benchmark/{benchmark_id}', '\\BitGoblin\\Colossus\\Controllers\\ApiController:getBenchmark')->setName('api.benchmark');
});