This commit is contained in:
2025-11-30 21:57:51 +01:00
parent 14ddfba2a4
commit b308bc106c
2 changed files with 19 additions and 12 deletions

View File

@@ -1,10 +1,10 @@
<?php
// /api/index.php
// Optional: zentrale Config laden (wenn du magst)
declare(strict_types=1);
$apibasedir = $_SERVER['DOCUMENT_ROOT'];
require $apibasedir. '/../config/fileload.php';
$apibasedir = $_SERVER['DOCUMENT_ROOT']; // bei dir: /.../projects/usbcheck/staging/api
require $apibasedir . '/../config/fileload.php';
// Basis-Header (CORS, JSON)
header('Content-Type: application/json; charset=utf-8');
@@ -41,12 +41,18 @@ if ($path === '/') {
// Routing nach Bereich
if (str_starts_with($path, '/v1/')) {
require_once $apibasedir.'/router/router.v1.php';
// alles hinter /v1/ in Segmente zerlegen
$rel = substr($path, strlen('/v1/')); // z.B. "browser.quick.test" oder "quickcheck" oder "foo/bar"
$rel = ltrim($rel, '/');
$segments = $rel === '' ? [] : explode('/', $rel);
require_once $apibasedir . '/router/router.v1.php';
router_v1_dispatch($segments);
exit;
}
if (str_starts_with($path, '/internal/')) {
require_once $apibasedir. '/router/router.internal.php';
require_once $apibasedir . '/router/router.internal.php';
exit;
}