added logic / Form stuff

This commit is contained in:
StockiP
2022-05-02 09:21:19 +02:00
parent 664bf41c91
commit 4e6af105f5
6 changed files with 115 additions and 55 deletions

46
logic/serviceLogic.php Normal file
View File

@@ -0,0 +1,46 @@
<?php
include( $_SERVER['DOCUMENT_ROOT'] . '/logic/userLogic.php' );
$param = "";
$method = "";
isset($_GET["method"]) ? $method = $_GET["method"] : false;
isset($_GET["param"]) ? $param = $_GET["param"] : false;
$logic = new UserLogic();
$result = $logic->handleUserRequests($method, $param);
if ($result == null) {
response("GET", 400, null);
} else {
response("GET", 200, $result);
}
function response($method, $status, $data)
{
header('Content-Type: application/json');
switch ($method) {
case 'GET':
http_response_code($status);
echo json_encode($data);
break;
case 'POST':
http_response_code($status);
echo json_encode($data);
break;
case 'PUT':
http_response_code($status);
echo json_encode($data);
break;
case 'DELETE':
http_response_code($status);
echo json_encode($data);
break;
default:
http_response_code(400);
echo json_encode(array("message" => "Invalid method"));
break;
}
}
?>