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 @@ 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'); } }