Files
iblogs/src/Api/Action/ApiAction.php
Sam Kintop bf3870ccca
Some checks failed
Publish Docker Image / build-and-push (push) Failing after 2m13s
all
2026-04-30 09:44:02 -05:00

37 lines
906 B
PHP

<?php
namespace Aternos\Mclogs\Api\Action;
use Aternos\Mclogs\Api\ContentParser;
use Aternos\Mclogs\Api\Response\ApiResponse;
use Aternos\Mclogs\Router\Action;
abstract class ApiAction extends Action
{
abstract protected function runApi(): ApiResponse;
protected function getAllowedOrigin(): string
{
return '*';
}
protected function shouldAllowCredentials(): bool
{
return false;
}
public function run(): bool
{
header('Access-Control-Allow-Origin: ' . $this->getAllowedOrigin());
header('Access-Control-Allow-Headers: *');
if ($this->shouldAllowCredentials()) {
header('Access-Control-Allow-Credentials: true');
}
header("Accept-Encoding: " . implode(",", ContentParser::getSupportedEncodings()));
$response = $this->runApi();
$response->output();
return true;
}
}