removed custom log
This commit is contained in:
parent
c2ef0e9248
commit
ce0d101ffe
|
@ -8,23 +8,9 @@ error_reporting(error_level: E_ALL);
|
||||||
|
|
||||||
require dirname(path: __DIR__) . '/vendor/autoload.php';
|
require dirname(path: __DIR__) . '/vendor/autoload.php';
|
||||||
|
|
||||||
// read config
|
|
||||||
$configFile = dirname(path: __DIR__) . "/config.json";
|
|
||||||
$configJSON = file_get_contents(filename: $configFile);
|
|
||||||
$config = json_decode(json: $configJSON, associative: true);
|
|
||||||
|
|
||||||
|
|
||||||
// TODO make a log class
|
|
||||||
$oFile = fopen(filename: 'log.txt', mode: 'a');
|
|
||||||
|
|
||||||
$uri = parse_url(url: $_SERVER['REQUEST_URI'], component: PHP_URL_PATH);
|
$uri = parse_url(url: $_SERVER['REQUEST_URI'], component: PHP_URL_PATH);
|
||||||
fputs(stream: $oFile, data: $uri . PHP_EOL);
|
|
||||||
fputs(stream: $oFile, data: "here");
|
|
||||||
|
|
||||||
$uri = explode(separator: '/', string: $uri);
|
$uri = explode(separator: '/', string: $uri);
|
||||||
|
|
||||||
fclose(stream: $oFile);
|
|
||||||
|
|
||||||
if ($uri[1] !== 'api') {
|
if ($uri[1] !== 'api') {
|
||||||
$scheme = $_SERVER['REQUEST_SCHEME'];
|
$scheme = $_SERVER['REQUEST_SCHEME'];
|
||||||
$host = $_SERVER['SERVER_NAME'];
|
$host = $_SERVER['SERVER_NAME'];
|
||||||
|
@ -32,23 +18,20 @@ if ($uri[1] !== 'api') {
|
||||||
header(header: "Location: $header");
|
header(header: "Location: $header");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
// TODO only valid clients?
|
|
||||||
header(header: "Access-Control-Allow-Origin: *");
|
header(header: "Access-Control-Allow-Origin: *");
|
||||||
header(header: "Content-Type: application/json; charset=UTF-8");
|
header(header: "Content-Type: application/json; charset=UTF-8");
|
||||||
header(header: "Access-Control-Allow-Methods: OPTIONS,GET,POST,PUT,DELETE");
|
header(header: "Access-Control-Allow-Methods: OPTIONS,GET,POST,PUT,DELETE");
|
||||||
header(header: "Access-Control-Max-Age: 3600");
|
header(header: "Access-Control-Max-Age: 3600");
|
||||||
header(header: "Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
|
header(header: "Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
|
||||||
|
|
||||||
|
|
||||||
$requestMethod = $_SERVER["REQUEST_METHOD"];
|
$requestMethod = $_SERVER["REQUEST_METHOD"];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$controller = new RequestController(config: $config, requestMethod: $requestMethod, uri: $uri);
|
$app = new BindAPI();
|
||||||
$controller->processRequest();
|
$app->handleRequest(requestMethod: $requestMethod, uri: $uri);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
echo json_encode(value: [
|
echo json_encode(value: [
|
||||||
'error' => $e->getMessage()
|
'error' => $e->getMessage()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue