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:
kj
2025-10-10 17:44:49 -03:00
parent b19e7d8789
commit a1a15f492c
4 changed files with 166 additions and 87 deletions

View File

@@ -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;
}
/**