改名
This commit is contained in:
@@ -58,7 +58,13 @@ abstract class Handler implements RequestHandlerInterface
|
||||
*/
|
||||
public function dispatcher(ServerRequestInterface $request): mixed
|
||||
{
|
||||
$response = call_user_func($this->handler->callback, ...$this->handler->params);
|
||||
if (!empty($this->handler->_aspect)) {
|
||||
$this->handler->_aspect->before();
|
||||
$response = $this->handler->_aspect->invoke($this->handler->callback, $this->handler->params);
|
||||
$this->handler->_aspect->after($response);
|
||||
} else {
|
||||
$response = call_user_func($this->handler->callback, ...$this->handler->params);
|
||||
}
|
||||
if (!($response instanceof ResponseInterface)) {
|
||||
$response = $this->transferToResponse($response);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use Closure;
|
||||
use Http\Handler\Abstracts\MiddlewareManager;
|
||||
use Kiri\Di\NoteManager;
|
||||
use Kiri\Events\EventProvider;
|
||||
use Kiri\IAspect;
|
||||
use Kiri\Kiri;
|
||||
use Server\Events\OnAfterWorkerStart;
|
||||
|
||||
@@ -23,6 +24,9 @@ class Handler
|
||||
public ?array $params = [];
|
||||
|
||||
|
||||
public IAspect $_aspect;
|
||||
|
||||
|
||||
public ?array $_middlewares = [];
|
||||
|
||||
|
||||
@@ -65,16 +69,7 @@ class Handler
|
||||
if (empty($aspect)) {
|
||||
return;
|
||||
}
|
||||
$callback = $this->callback;
|
||||
$params = $this->params;
|
||||
|
||||
$this->params = [];
|
||||
$this->callback = static function () use ($aspect, $callback, $params) {
|
||||
$aspect->before();
|
||||
$result = $aspect->invoke($callback, $params);
|
||||
$aspect->after($result);
|
||||
return $result;
|
||||
};
|
||||
$this->_aspect = $aspect;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user