microserviciile de register, login finalizate
This commit is contained in:
Executable
+37
@@ -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"];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user