添加后台代理代码

This commit is contained in:
2026-03-15 01:27:05 +08:00
parent 11f9ac4dc1
commit ea08c9366a
5254 changed files with 721042 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
<?php
namespace phprs;
use phprs\util\IoCFactory;
use phprs\util\exceptions\NotFound;
use phprs\util\exceptions\BadRequest;
use phprs\util\exceptions\Forbidden;
class Bootstrap
{
static public function run($conf_file)
{
$err = null;
$protocol = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0');
//执行请求
try
{
require_once __DIR__ . '/AutoLoad.php';
$factory = new IoCFactory($conf_file);
$router = $factory->create('phprs\\RouterWithCache');
//var_dump($router);
$router();
}
catch (NotFound $e)
{
header($protocol . ' 404 Not Found');
$err = $e;
}
catch (BadRequest $e)
{
header($protocol . ' 400 Bad Request');
$err = $e;
}
catch (Forbidden $e)
{
header($protocol . ' 403 Forbidden');
$err = $e;
}
catch (\Exception $e)
{
header($protocol . ' 500 Internal Server Error');
$err = $e;
}
if ($err)
{
header("Content-Type: application/json; charset=UTF-8");
$estr = array(
'error' => get_class($err),
'message' => $err->getMessage(),
);
echo json_encode($estr, JSON_UNESCAPED_UNICODE);
}
}
}