microserviciile de register, login finalizate

This commit is contained in:
Cerbu Andrei Mihnea
2023-06-15 22:21:53 +03:00
parent a739a66ae4
commit 4e585ba278
159 changed files with 4775 additions and 1747 deletions
+37
View File
@@ -0,0 +1,37 @@
<?php
namespace app\core;
class Request{
public function method(): string
{
return $_SERVER['REQUEST_METHOD'];
}
public function getAuthToken(): ?string
{
return array_key_exists("Authorization", apache_request_headers()) ?
apache_request_headers()["Authorization"] : NULL;
}
public function getAuthRequest(): ?string
{
return array_key_exists("Auth-Request", apache_request_headers()) ?
apache_request_headers()["Auth-Request"] : NULL;
}
public function getBody(): ?array
{
if(!array_key_exists("Content-Length", apache_request_headers())) return NULL;
$bytesToRead = intval(apache_request_headers()["Content-Length"]);
if($bytesToRead == 0) return NULL;
$inputStream = fopen('php://input', 'r');
$jsonData = fread($inputStream, $bytesToRead);
$jsonData = json_decode($jsonData, true);
fclose($inputStream);
return empty($jsonData["values"]) ? [] : $jsonData["values"];
}
}