Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
Set up Slim to return JSON data
Browse files Browse the repository at this point in the history
  • Loading branch information
programarivm committed Nov 24, 2023
1 parent ae3c418 commit b4db1be
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 2 deletions.
10 changes: 9 additions & 1 deletion app/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use App\Application\Actions\User\ListUsersAction;
use App\Application\Actions\User\ViewUserAction;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\App;
use Slim\Http\Response as Response;
use Slim\Interfaces\RouteCollectorProxyInterface as Group;
use Slim\Views\PhpRenderer;

Expand All @@ -30,4 +30,12 @@
$renderer = new PhpRenderer('../templates');
return $renderer->render($response, "about.html.php");
});

$app->post('/api/heuristics', function (Request $request, Response $response) {
$params = $request->getParsedBody();

// TODO

return $response->withJson($params, 200);
});
};
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"chesslablab/php-chess": "^1.3",
"monolog/monolog": "^2.8",
"php-di/php-di": "^6.4",
"slim/http": "^1.3",
"slim/php-view": "^3.2",
"slim/psr7": "^1.5",
"slim/slim": "^4.10"
Expand Down
79 changes: 78 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b4db1be

Please sign in to comment.