<?php
header("Content-Type: application/json");

// Parse request URI
$request = $_SERVER['REQUEST_URI'];

// Route based on keyword in URI
switch (true) {
    case strpos($request, 'register') !== false:
        require __DIR__ . '/endpoints/register.php';
        break;

    case strpos($request, 'property') !== false:
        require __DIR__ . '/endpoints/property.php';
        break;

    case strpos($request, 'states') !== false:
        require __DIR__ . '/endpoints/states.php';
        break;

    case strpos($request, 'ticket') !== false:
        require __DIR__ . '/endpoints/ticket.php';
        break;

    default:
        echo json_encode(["error" => "Invalid endpoint"]);
}