From 8af61f97b06b79ea02b136dde4e2f16119f156f9 Mon Sep 17 00:00:00 2001 From: Jeroen De Meerleer Date: Thu, 13 Jun 2024 17:43:32 +0200 Subject: [PATCH] Added /config endpoint and link in 404 page The update includes the addition of a new '/config' endpoint in index.php, which returns the application's configuration as a JSON response. A corresponding link to this new endpoint has also been added to the 404 error page. --- index.php | 4 ++++ templates/404.twig | 1 + 2 files changed, 5 insertions(+) diff --git a/index.php b/index.php index 0d7825a..4ad662a 100644 --- a/index.php +++ b/index.php @@ -6,6 +6,10 @@ if($_SERVER["REQUEST_URI"] == '/metrics') { $phpbin = getenv('PHP_BINARY'); $output = shell_exec('CONFIG_FILE="' . $config . '" ' . $phpbin . ' ' . $_SERVER['DOCUMENT_ROOT'] . 'script.php'); echo $output; +} elseif ($_SERVER["REQUEST_URI"] == '/config') { + header('Content-Type: application/json'); + require_once getenv('CONFIG_FILE'); + echo json_encode($config); } elseif ($_SERVER["REQUEST_URI"] == '/version') { header('Content-Type: application/json'); $git = [ diff --git a/templates/404.twig b/templates/404.twig index 76ee3af..f68e587 100644 --- a/templates/404.twig +++ b/templates/404.twig @@ -8,6 +8,7 @@

404 Uri {{ path }} not found

/metrics

+

/config

/version

\ No newline at end of file