- Created complete documentation in docs/ directory - Added PROJECT_OVERVIEW.md with feature highlights and getting started guide - Added ARCHITECTURE.md with system design and technical details - Added SECURITY.md with comprehensive security implementation guide - Added DEVELOPMENT.md with development workflows and best practices - Added DEPLOYMENT.md with production deployment instructions - Added API.md with complete REST API documentation - Added CONTRIBUTING.md with contribution guidelines - Added CHANGELOG.md with version history and migration notes - Reorganized all documentation files into docs/ directory for better organization - Updated README.md with proper documentation links and quick navigation - Enhanced project structure with professional documentation standards
76 lines
2.3 KiB
PHP
76 lines
2.3 KiB
PHP
<?php
|
|
/*******************************************************************************************************************
|
|
| EasyStream REST API v1
|
|
| Main API endpoint handler for mobile apps and third-party integration
|
|
|*******************************************************************************************************************/
|
|
|
|
define('_ISVALID', true);
|
|
require_once '../../../f_core/config.core.php';
|
|
|
|
// Set JSON response headers
|
|
header('Content-Type: application/json');
|
|
header('Access-Control-Allow-Origin: *');
|
|
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS');
|
|
header('Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With');
|
|
|
|
try {
|
|
$api = new VAPI();
|
|
|
|
// Get request method and endpoint
|
|
$method = $_SERVER['REQUEST_METHOD'] ?? 'GET';
|
|
$requestUri = $_SERVER['REQUEST_URI'] ?? '';
|
|
|
|
// Parse endpoint from URI
|
|
$basePath = '/api/v1/';
|
|
$endpoint = '';
|
|
|
|
if (strpos($requestUri, $basePath) !== false) {
|
|
$endpoint = substr($requestUri, strpos($requestUri, $basePath) + strlen($basePath));
|
|
$endpoint = strtok($endpoint, '?'); // Remove query parameters
|
|
}
|
|
|
|
// Get request data
|
|
$data = [];
|
|
if ($method === 'GET') {
|
|
$data = $_GET;
|
|
} else {
|
|
$input = file_get_contents('php://input');
|
|
if ($input) {
|
|
$data = json_decode($input, true) ?: [];
|
|
}
|
|
// Merge with POST data if available
|
|
$data = array_merge($data, $_POST);
|
|
}
|
|
|
|
// Get request headers
|
|
$headers = getallheaders() ?: [];
|
|
|
|
// Handle API request
|
|
$response = $api->handleRequest($method, $endpoint, $data, $headers);
|
|
|
|
// Set HTTP status code
|
|
http_response_code($response['status']);
|
|
|
|
// Return JSON response
|
|
echo json_encode($response);
|
|
|
|
} catch (Exception $e) {
|
|
// Log error
|
|
$logger = VLogger::getInstance();
|
|
$logger->error('API error', [
|
|
'error' => $e->getMessage(),
|
|
'method' => $_SERVER['REQUEST_METHOD'] ?? '',
|
|
'uri' => $_SERVER['REQUEST_URI'] ?? '',
|
|
'trace' => $e->getTraceAsString()
|
|
]);
|
|
|
|
// Return error response
|
|
http_response_code(500);
|
|
echo json_encode([
|
|
'status' => 500,
|
|
'data' => ['error' => 'Internal server error'],
|
|
'timestamp' => time(),
|
|
'version' => 'v1'
|
|
]);
|
|
}
|
|
?>
|