Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F56952407
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/Service.php b/src/Service.php
index 6da464d..0cce7a8 100644
--- a/src/Service.php
+++ b/src/Service.php
@@ -1,64 +1,64 @@
<?php
namespace Nasqueron\Api\ServersLog;
use Dotenv\Dotenv;
class Service extends BaseService {
///
/// Initialisation
///
public function __construct () {
$this->loadEnvironment();
}
///
/// Controller
///
private function isAliveRequest() : bool {
return
$_SERVER['REQUEST_METHOD'] === "GET"
&&
- $_SERVER['REQUEST_URI'] === '/status';
+ $_SERVER['DOCUMENT_URI'] === '/status';
}
public function handle () : void {
if ($this->isAliveRequest()) {
$this->sendSuccessResponse("ALIVE");
} elseif ($_SERVER['REQUEST_METHOD'] === "PUT") {
$body = $this->getBodyObject();
$this->put($body);
} else {
$this->sendInvalidMethodResponse();
}
}
public function put ($data) : void {
Log::addEntryToJSONFile(
self::getServersLogFile(),
LogEntry::fromJSON($data)
);
$this->sendSuccessResponse();
}
///
/// Helper methods
///
private function loadEnvironment () : void {
$env = new Dotenv(__DIR__);
if (file_exists(__DIR__ . '/.env')) {
$env->load();
}
$env->required('SERVERS_LOG_FILE');
}
private static function getServersLogFile () : string {
return getenv('SERVERS_LOG_FILE');
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Fri, Nov 13, 13:54 (3 d, 11 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4238396
Default Alt Text
(1 KB)
Attached To
Mode
rAPISRVLOGS Servers log :: Add new entries API
Attached
Detach File
Event Timeline
Log In to Comment