modified version update

This commit is contained in:
tracer 2024-04-30 14:08:59 +02:00
parent 7b40624218
commit 514c77de55
3 changed files with 18 additions and 7 deletions

View File

@ -2,7 +2,7 @@
"name": "24unix/bindapi",
"description": "manage Bind9 DNS server via REST API",
"version": "1.0.9",
"build_number": "366",
"build_number": "367",
"authors": [
{
"name": "Micha Espey",

View File

@ -58,6 +58,7 @@ class RequestController
// server tag
private string $baseDir;
#[OAT\Get(
path: '/ping',
@ -113,7 +114,15 @@ class RequestController
{
if ($this->validateApiKey()) {
$this->status = '200 OK';
$this->response = '1.2.3';
$composerJson = json_decode(json: file_get_contents(filename: $this->baseDir . 'composer.json'));
$version = $composerJson->version;
$buildNumber = $composerJson->build_number;
$this->result = [
'version' => $version,
'buildnumber' => $buildNumber,
];
} else {
$this->status = '401 Unauthorized';
$this->message = 'API key is missing or invalid';
@ -653,6 +662,8 @@ class RequestController
private readonly EncryptionController $encryptionController,
private readonly Logger $logger)
{
$this->baseDir = dirname(path: __DIR__, levels: 2) . '/';
$this->status = '';
$this->response = '';
$this->message = '';

View File

@ -39,11 +39,11 @@ if (array_key_exists(key: 'v', array: $options) || array_key_exists(key: 'versio
$authorName = $authors[0]->name;
$authorEmail = $authors[0]->email;
echo 'Name: $name' . PHP_EOL;
echo 'Description: $description' . PHP_EOL;
echo 'Version: $version' . PHP_EOL;
echo 'Build Number: $buildNumber' . PHP_EOL;
echo 'Author: $authorName ($authorEmail)' . PHP_EOL;
echo "Name: $name" . PHP_EOL;
echo "Description: $description" . PHP_EOL;
echo "Version: $version" . PHP_EOL;
echo "Build Number: $buildNumber" . PHP_EOL;
echo "Author: $authorName ($authorEmail)" . PHP_EOL;
exit(0);
}