58 lines
1.5 KiB
PHP
58 lines
1.5 KiB
PHP
<?php
|
|
/**
|
|
* Request - DuckBrain
|
|
*
|
|
* Libería complementaria de la libería Router.
|
|
* Contiene el cuerpo básico de la petición http (POST, GET, JSON, etc).
|
|
*
|
|
* @author KJ
|
|
* @website https://kj2.me
|
|
* @licence MIT
|
|
*/
|
|
|
|
namespace Libs;
|
|
|
|
class Request extends Neuron {
|
|
/**
|
|
* @var Neuron $get Objeto con todos los valores de $_GET.
|
|
*/
|
|
public Neuron $get;
|
|
/**
|
|
* @var Neuron $post Objeto con todos los valores de $_POST.
|
|
*/
|
|
public Neuron $post;
|
|
/**
|
|
* @var Neuron $json Objeto con todos los valores json enviados.
|
|
*/
|
|
public Neuron $json;
|
|
/**
|
|
* @var mixed $params Objeto con todos los valores pseudovariables de la uri.
|
|
*/
|
|
public Neuron $params;
|
|
/**
|
|
* @var mixed $path Ruta actual tomando como raíz la instalación de DuckBrain.
|
|
*/
|
|
public string $path;
|
|
|
|
/**
|
|
* __construct
|
|
*
|
|
* @param string $path Ruta actual tomando como raíz la instalación de DuckBrain.
|
|
*/
|
|
public function __construct(string $path = '/') {
|
|
$this->path = $path;
|
|
$this->get = new Neuron($_GET);
|
|
$this->post = new Neuron($_POST);
|
|
|
|
$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)
|
|
);
|
|
else
|
|
$this->json = new Neuron();
|
|
|
|
$this->params = new Neuron();
|
|
}
|
|
}
|