diff --git a/includes/restapi.php b/includes/restapi.php index 2a1be6d8..1338d24d 100644 --- a/includes/restapi.php +++ b/includes/restapi.php @@ -49,11 +49,18 @@ function DisplayRestAPI() array_shift($output); $serviceLog = implode("\n", $output); + if ($serviceStatus == "up") { + $docUrl = getDocUrl(); + $faicon = ""; + $docMsg = sprintf(_("RestAPI docs are accessible here%s"),$docUrl, $faicon); + } + echo renderTemplate("restapi", compact( "status", "apiKey", "serviceStatus", - "serviceLog" + "serviceLog", + "docMsg" )); } @@ -72,3 +79,13 @@ function saveAPISettings($status, $apiKey, $dotenv) return $status; } +// Returns a url for fastapi's automatic docs +function getDocUrl() +{ + $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://'; + $server_name = $_SERVER['SERVER_NAME']; + $port = 8081; + $url = $protocol . $server_name .':'. $port . '/docs'; + return $url; +} + diff --git a/templates/restapi/general.php b/templates/restapi/general.php index b39c293c..07f12406 100644 --- a/templates/restapi/general.php +++ b/templates/restapi/general.php @@ -1,8 +1,13 @@

-
+
+
+ +
+
+