Save body request as a property.

This commit is contained in:
kj 2025-02-20 08:21:05 -03:00
parent 45abea5301
commit 595e9c1316

View File

@ -22,6 +22,7 @@ class Request extends Neuron {
public Neuron $params;
public string $path;
public string $error;
public string $body;
public array $next;
/**
@ -37,11 +38,12 @@ class Request extends Neuron {
$this->put = new Neuron();
$this->patch = new Neuron();
$this->delete = new Neuron();
$this->body = file_get_contents("php://input");
$contentType = isset($_SERVER["CONTENT_TYPE"]) ? trim($_SERVER["CONTENT_TYPE"]) : '';
if ($contentType === "application/json")
$this->json = new Neuron(
(object) json_decode(trim(file_get_contents("php://input")), false)
(object) json_decode(trim($this->body), false)
);
else {
$this->json = new Neuron();