This commit is contained in:
as2252258@163.com
2021-09-19 16:42:29 +08:00
parent d77f5b16c3
commit ff58d0faef
16 changed files with 256 additions and 262 deletions
+3 -10
View File
@@ -6,6 +6,7 @@ use Http\Handler\Handler as CHl;
use Http\Message\ServerRequest;
use Kiri\Core\Help;
use Kiri\Kiri;
use Kiri\Proxy\AspectProxy;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
@@ -74,16 +75,8 @@ abstract class Handler implements RequestHandlerInterface
*/
protected function dispatcher(ServerRequestInterface $request): mixed
{
if ($this->handler->callback instanceof \Closure) {
$response = call_user_func($this->handler->callback, ...$this->handler->params);
} else {
[$controller, $action] = $this->handler->callback;
$controller = Kiri::getDi()->get($controller);
$response = call_user_func([$controller, $action], ...$this->handler->params);
}
if (!($response instanceof ResponseInterface)) {
$aspect = Kiri::getDi()->get(AspectProxy::class);
if (!(($response = $aspect->proxy($this->handler)) instanceof ResponseInterface)) {
$response = $this->transferToResponse($response);
}
$response->withHeader('Run-Time', $this->_runTime($request));