Page MenuHomeDevCentral

D1293.diff
No OneTemporary

D1293.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, 11:13 (13 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2260061
Default Alt Text
D1293.diff (1 KB)

Event Timeline