Skip to content

Commit

Permalink
handle error better, add incomplete functions for all valid routes
Browse files Browse the repository at this point in the history
  • Loading branch information
creme332 committed Apr 20, 2024
1 parent b2f15db commit 14288d6
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/controllers/api/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}

0 comments on commit 14288d6

Please sign in to comment.