mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
Added proof of concept for controllers system
This commit is contained in:
25
public_html/api-dispatch.php
Normal file
25
public_html/api-dispatch.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
require_once('..' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'AutoLoader.php');
|
||||
|
||||
function injectControllers($router)
|
||||
{
|
||||
\Szurubooru\Controllers\AuthController::register($router);
|
||||
}
|
||||
|
||||
$router = new \Szurubooru\Router;
|
||||
injectControllers($router);
|
||||
|
||||
try
|
||||
{
|
||||
$json = $router->handle($_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$json = [
|
||||
'error' => $e->getMessage(),
|
||||
'trace' => $e->getTrace(),
|
||||
];
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($json);
|
Reference in New Issue
Block a user