Add SportPath auth APIs and training content foundation
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once dirname(__DIR__, 4) . '/backend/Config.php';
|
||||
require_once dirname(__DIR__, 4) . '/backend/Database.php';
|
||||
|
||||
function api_json(array $payload, int $status = 200): void
|
||||
{
|
||||
http_response_code($status);
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
header('Cache-Control: no-store');
|
||||
header('X-Content-Type-Options: nosniff');
|
||||
header('Referrer-Policy: no-referrer');
|
||||
header('X-Frame-Options: DENY');
|
||||
echo json_encode($payload, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
exit;
|
||||
}
|
||||
|
||||
function api_method(string $expected): void
|
||||
{
|
||||
if (($_SERVER['REQUEST_METHOD'] ?? 'GET') !== $expected) {
|
||||
header('Allow: ' . $expected);
|
||||
api_json(['error' => 'method_not_allowed'], 405);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user