Page MenuHomeDevCentral

D1293.id3324.diff
No OneTemporary

D1293.id3324.diff

diff --git a/src/BaseService.php b/src/BaseService.php
--- a/src/BaseService.php
+++ b/src/BaseService.php
@@ -22,8 +22,9 @@
}
}
- protected function sendSuccessResponse () {
+ protected function sendSuccessResponse ($responseBody = '') {
// HTTP 200 OK
+ echo $responseBody;
}
protected function sendInvalidMethodResponse () {
diff --git a/src/Service.php b/src/Service.php
--- a/src/Service.php
+++ b/src/Service.php
@@ -18,15 +18,22 @@
/// Controller
///
- public function handle () : void {
- $body = $this->getBodyObject();
+ private function isAliveRequest() : bool {
+ return
+ $_SERVER['REQUEST_METHOD'] === "GET"
+ &&
+ $_SERVER['REQUEST_URI'] === '/status';
+ }
- if ($_SERVER['REQUEST_METHOD'] === "PUT") {
+ public function handle () : void {
+ if ($this->isAliveRequest()) {
+ $this->sendSuccessResponse("ALIVE");
+ } elseif ($_SERVER['REQUEST_METHOD'] === "PUT") {
+ $body = $this->getBodyObject();
$this->put($body);
- return;
+ } else {
+ $this->sendInvalidMethodResponse();
}
-
- $this->sendInvalidMethodResponse();
}
public function put ($data) : void {

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 24, 13:24 (8 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2260061
Default Alt Text
D1293.id3324.diff (1 KB)

Event Timeline