Add APIController.php , delete tmp.php, create some directories to organise the API and finalize the connection to the database
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
8f49d13d14
commit
ed8ab0d398
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
class APIController
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
try {
|
||||
if (empty($_REQUEST['action'])) {
|
||||
$action = NULL;
|
||||
} else {
|
||||
$action = $_REQUEST['action'];
|
||||
}
|
||||
$listGateway = array(""); //TODO : nom des différentes Gateway à mettre
|
||||
foreach ($listGateway as $gateway) // Pour chaque Gateway
|
||||
{
|
||||
/* On regarde s'il implémente une fonction du même nom que l'action reçue */
|
||||
if(method_exists($gateway, $action))
|
||||
{
|
||||
(new $gateway)->$action(); // Si oui, on appelle cette fonction
|
||||
}
|
||||
}
|
||||
|
||||
} catch (PDOException) {
|
||||
return http_response_code(404);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
require_once "./Connection.php";
|
||||
|
||||
function connect(): int|Connection
|
||||
{
|
||||
|
||||
$dsn = "mysql:host=".$_ENV["HOST"].";dbname=".$_ENV["DATABASE"].";";
|
||||
$login = $_ENV["USER"];
|
||||
$password = $_ENV["PASSWORD"];
|
||||
|
||||
try {
|
||||
|
||||
$connection = new Connection($dsn,$login,$password);
|
||||
|
||||
}catch (PDOException){
|
||||
|
||||
http_response_code(404);
|
||||
return http_response_code();
|
||||
}
|
||||
return $connection;
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once "./Connection.php";
|
||||
|
||||
$dsn = "mysql:host=".$_ENV["HOST"].";dbname=".$_ENV["DATABASE"].";";
|
||||
$login = $_ENV["USER"];
|
||||
$password = $_ENV["PASSWORD"];
|
||||
|
||||
try {
|
||||
|
||||
$connection = new Connection($dsn,$login,$password);
|
||||
|
||||
echo "Connection OK !";
|
||||
|
||||
}catch (PDOException $PDOException){
|
||||
echo $PDOException->getMessage();
|
||||
echo $PDOException->getCode();
|
||||
phpinfo();
|
||||
return http_response_code(404);
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
<?php
|
||||
|
||||
echo "<h1>HEY</h1>";
|
Loading…
Reference in new issue