mirror of https://github.com/byecorps/id.git
Create database connection and add API route
This commit is contained in:
parent
97cf3b02ac
commit
3fbcfa7159
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
$response = [
|
||||||
|
"response" => [
|
||||||
|
"success" => false,
|
||||||
|
"status_code" => 404
|
||||||
|
],
|
||||||
|
'body' => [
|
||||||
|
'message' => 'That endpoint could not be found.'
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
echo json_encode($response, JSON_PRETTY_PRINT);
|
|
@ -8,7 +8,12 @@ try {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Init PDO.
|
// Connect to database
|
||||||
|
try {
|
||||||
|
$pdo = new PDO(DB_DSN, DB_USERNAME, DB_PASSWORD, PDO_OPTIONS);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
echo "<b>Critical error:</b> " . $e->getMessage() . "<br />";
|
||||||
|
}
|
||||||
|
|
||||||
// Starts the session
|
// Starts the session
|
||||||
// TODO: write this to use the database to work across more than one server
|
// TODO: write this to use the database to work across more than one server
|
||||||
|
@ -29,6 +34,7 @@ if (str_ends_with($path, '/') && $path != '/') {
|
||||||
|
|
||||||
$routes = [
|
$routes = [
|
||||||
'' => function () { require 'views/home.php'; },
|
'' => function () { require 'views/home.php'; },
|
||||||
|
'api' => function () { require 'api.php'; /* Handoff further routing to API script. */ }
|
||||||
];
|
];
|
||||||
|
|
||||||
//print_r($path_array);
|
//print_r($path_array);
|
||||||
|
|
Loading…
Reference in New Issue