You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Application-Web/public/api/index.php

29 lines
834 B

<?php
require "../../config.php";
require "../../vendor/autoload.php";
require "../../sql/database.php";
use App\Api\TacticEndpoint;
use App\Connexion;
use App\Gateway\TacticInfoGateway;
$con = new Connexion(get_database());
$router = new AltoRouter();
$router->setBasePath("/api");
$tacticEndpoint = new TacticEndpoint(new TacticInfoGateway($con));
$router->map("POST", "/tactic/[i:id]/edit/name", fn(int $id) => $tacticEndpoint->update_name($id));
$router->map("GET", "/tactic/[i:id]", fn(int $id) => $tacticEndpoint->get_tactic_info($id));
$router->map("POST", "/tactic/new", fn() => $tacticEndpoint->new_tactic());
$match = $router->match();
if ($match == null) {
echo "404 not found";
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
exit(1);
}
call_user_func_array($match['target'], $match['params']);