refactor!: add Synapsis for dependency resolution and injection
- Remove Middleware class and custom callback handling logic. - Implement Synapsis as a dependency injection container for automatic resolution. - Refactor Router to use Synapsis for process route callbacks and not found handler. - Update Request to remove middleware-specific properties and use Router::$currentParams for path parameters.
This commit is contained in:
@@ -24,7 +24,6 @@ class Request extends Neuron
|
||||
public string $path;
|
||||
public string $error;
|
||||
public string $body;
|
||||
public array $next;
|
||||
|
||||
/**
|
||||
* __construct
|
||||
@@ -39,6 +38,7 @@ class Request extends Neuron
|
||||
$this->put = new Neuron();
|
||||
$this->patch = new Neuron();
|
||||
$this->delete = new Neuron();
|
||||
$this->params = new Neuron(Router::$currentParams);
|
||||
$this->body = file_get_contents("php://input");
|
||||
|
||||
$contentType = isset($_SERVER["CONTENT_TYPE"]) ? trim($_SERVER["CONTENT_TYPE"]) : '';
|
||||
@@ -60,21 +60,10 @@ class Request extends Neuron
|
||||
}
|
||||
}
|
||||
|
||||
$this->params = new Neuron();
|
||||
}
|
||||
|
||||
/**
|
||||
* Corre las validaciones e intenta continuar con la pila de callbacks.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(): mixed
|
||||
{
|
||||
if ($this->validate()) {
|
||||
return Middleware::next($this);
|
||||
// Corremos las validaciones configuradas
|
||||
if (!$this->validate()) {
|
||||
exit();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user