From b15983ceaef4f9f2c076a0a0bf2dddeb69fdaef5 Mon Sep 17 00:00:00 2001 From: Victor Westerlund Date: Mon, 8 Feb 2021 12:38:13 +0100 Subject: [PATCH] Added status checker endpoint for Shields.io Added status checker endpoint for Shields.io under "status.php" Added router.php and reference in server.conf Removed ping.php --- .gitignore | 2 +- api/endpoint/ping.php | 3 --- api/endpoint/status.php | 32 ++++++++++++++++++++++++++++++++ server.conf | 4 +--- 4 files changed, 34 insertions(+), 7 deletions(-) delete mode 100644 api/endpoint/ping.php create mode 100644 api/endpoint/status.php diff --git a/.gitignore b/.gitignore index 9d988e5..9abf34b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ .well-known/ api/endpoint/* -!api/endpoint/ping.php \ No newline at end of file +!api/endpoint/status.php \ No newline at end of file diff --git a/api/endpoint/ping.php b/api/endpoint/ping.php deleted file mode 100644 index 019f31c..0000000 --- a/api/endpoint/ping.php +++ /dev/null @@ -1,3 +0,0 @@ - 1, + "label" => "API", + "message" => $message, + "color" => $color, + "isError" => $isError + ]; + + echo json_encode($response); + } + + function getStatus() { + if(!is_dir($api)) { + response(false); + return false; + } + + response(true); + } + + getStatus(); \ No newline at end of file diff --git a/server.conf b/server.conf index 2df83e2..fe8cda0 100644 --- a/server.conf +++ b/server.conf @@ -59,15 +59,13 @@ server { root /var/www/victorwesterlund.com/api/endpoint; - index router.php; - location / { try_files $uri $uri.html $uri/ @extensionless-php; index index.html index.htm index.php; } location ~ \.php$ { - try_files $uri $uri/ =404; + try_files $uri $uri/ /router.php =404; add_header Access-Control-Allow-Origin *; include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.3-fpm.sock;