Add delete request params.
This commit is contained in:
parent
d441f001ec
commit
45abea5301
@ -17,6 +17,7 @@ class Request extends Neuron {
|
||||
public Neuron $post;
|
||||
public Neuron $put;
|
||||
public Neuron $patch;
|
||||
public Neuron $delete;
|
||||
public Neuron $json;
|
||||
public Neuron $params;
|
||||
public string $path;
|
||||
@ -35,6 +36,7 @@ class Request extends Neuron {
|
||||
$this->post = new Neuron($_POST);
|
||||
$this->put = new Neuron();
|
||||
$this->patch = new Neuron();
|
||||
$this->delete = new Neuron();
|
||||
|
||||
$contentType = isset($_SERVER["CONTENT_TYPE"]) ? trim($_SERVER["CONTENT_TYPE"]) : '';
|
||||
if ($contentType === "application/json")
|
||||
@ -43,7 +45,7 @@ class Request extends Neuron {
|
||||
);
|
||||
else {
|
||||
$this->json = new Neuron();
|
||||
if (in_array($_SERVER['REQUEST_METHOD'], ['PUT', 'PATCH'])) {
|
||||
if (in_array($_SERVER['REQUEST_METHOD'], ['PUT', 'PATCH', 'DELETE'])) {
|
||||
parse_str(file_get_contents("php://input"), $input_vars);
|
||||
$this->{strtolower($_SERVER['REQUEST_METHOD'])} = new Neuron($input_vars);
|
||||
}
|
||||
@ -73,8 +75,8 @@ class Request extends Neuron {
|
||||
public function validate(): bool
|
||||
{
|
||||
$actual = match($_SERVER['REQUEST_METHOD']) {
|
||||
'GET', 'DELETE' => $this->get,
|
||||
default => $this->{strtolower($_SERVER['REQUEST_METHOD'])}
|
||||
'POST', 'PUT', 'PATCH', 'DELETE' => $this->{strtolower($_SERVER['REQUEST_METHOD'])},
|
||||
default => $this->get
|
||||
};
|
||||
|
||||
if (Validator::validateList(static::paramRules(), $this->params) &&
|
||||
|
Loading…
Reference in New Issue
Block a user