added logic / Form stuff
This commit is contained in:
46
logic/serviceLogic.php
Normal file
46
logic/serviceLogic.php
Normal 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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user