hostas2/public/api/v1/router.php

19 lines
582 B
PHP
Raw Normal View History

2024-09-01 18:54:41 +00:00
<?php
require_once($_SERVER['DOCUMENT_ROOT'] . '/config.php');
// $clean_uri is the request URI with any query strings removed
$clean_uri = strtok($_SERVER['REQUEST_URI'], '?');
2024-09-01 18:54:41 +00:00
// e.g. /api/v1/test/request/ -> ['', 'api', 'v1', 'test', 'request'].
// For convenience later, we take a slice that excludes ['', 'api', 'v1'].
define('REQUEST_PATH', array_slice(explode('/', $clean_uri), offset: 3));
2024-09-01 18:54:41 +00:00
switch (REQUEST_PATH[0]) {
case 'actor': // /api/v1/actor
require_once($_SERVER['DOCUMENT_ROOT'] . '/api/v1/actor.php');
break;
default:
http_response_code(404);
die();
}