Added API handler for getting a benchmark's info
This commit is contained in:
parent
94794f2ca1
commit
b9b881ec0c
22
src/Controllers/ApiController.php
Normal file
22
src/Controllers/ApiController.php
Normal 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');
|
||||
}
|
||||
|
||||
}
|
@ -34,3 +34,7 @@ $app->group('/result', function(RouteCollectorProxy $group) {
|
||||
$app->group('/reports', function(RouteCollectorProxy $group) {
|
||||
$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');
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user