mirror of
https://codeberg.org/vlw/victorwesterlund.com.git
synced 2025-09-14 03:23:41 +02:00
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
This commit is contained in:
parent
70369f8163
commit
b15983ceae
4 changed files with 34 additions and 7 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,4 +1,4 @@
|
|||
.well-known/
|
||||
|
||||
api/endpoint/*
|
||||
!api/endpoint/ping.php
|
||||
!api/endpoint/status.php
|
|
@ -1,3 +0,0 @@
|
|||
<?php
|
||||
|
||||
echo "Pong";
|
32
api/endpoint/status.php
Normal file
32
api/endpoint/status.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
header("Content-Type: application/json");
|
||||
|
||||
$api = $_GET["api"];
|
||||
|
||||
function response($online = false) {
|
||||
$isError = $online ? true : false;
|
||||
$message = $online ? "Online" : "Offline";
|
||||
$color = $online ? "green" : "lightgrey";
|
||||
|
||||
$response = [
|
||||
"schemaVersion" => 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();
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue