modified: .gitignore

modified:   software/README.md
	modified:   software/app.php
	modified:   software/database/sqlite.php
	modified:   software/device-api.php
	modified:   software/router.php
This commit is contained in:
Sven Luethi committed 2024-07-08 00:33:40 +02:00
1 parent 50eec7e284
commit c44e580120
6 files changed
+62 -15

No files matched your search

+23 -3
View File
@@ -9,7 +9,7 @@ class Router
function __construct(IRequest $request)
{
$this->request = $request;
$this->request = $request;
}
function __call($name, $args)
@@ -100,8 +100,8 @@ class Request implements IRequest
foreach($matches[0] as $match)
{
$c = str_replace('_', '', strtoupper($match));
$result = str_replace($match, $c, $result);
$c = str_replace('_', '', strtoupper($match));
$result = str_replace($match, $c, $result);
}
return $result;
@@ -122,5 +122,25 @@ class Request implements IRequest
return $body;
}
}
public function getJSONBody()
{
if($this->requestMethod === "GET") { return; }
if($this->requestMethod === "POST")
{
//return filter_input(INPUT_POST, $_POST, FILTER_SANITIZE_SPECIAL_CHARS);
$json = file_get_contents('php://input');
// Decode the JSON data into a PHP array
$data = json_decode($json, true);
// Check for JSON parsing errors
if (json_last_error() !== JSON_ERROR_NONE) {
die('Invalid JSON received');
}
return $data;
}
}
}