From 14288d67bdd18d60f46137a6bb7e21b1ade2c9c1 Mon Sep 17 00:00:00 2001 From: creme332 <65414576+creme332@users.noreply.github.com> Date: Sat, 20 Apr 2024 11:02:08 +0400 Subject: [PATCH] handle error better, add incomplete functions for all valid routes --- src/controllers/api/Products.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/controllers/api/Products.php b/src/controllers/api/Products.php index 8ed792c..1b1f78d 100644 --- a/src/controllers/api/Products.php +++ b/src/controllers/api/Products.php @@ -21,14 +21,37 @@ private function getProducts(): void echo json_encode($result); } + private function addProduct(): void + { + } + + private function deleteProduct(): void + { + } + + private function updateProduct(): void + { + } + + public function index(): void { switch ($_SERVER['REQUEST_METHOD']) { case 'GET': $this->getProducts(); break; + case 'POST': + $this->addProduct(); + break; + case 'DELETE': + $this->deleteProduct(); + break; + case 'PUT': + $this->updateProduct(); + break; default: - echo json_encode("Error"); + http_response_code(400); + die(); } } } \ No newline at end of file