From 90b22a14e04cd3910e54cc0804ee821ee1bc689a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Tue, 26 Oct 2021 10:35:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- http-server/Server.php | 5 ----- http-server/ServerCommand.php | 13 +++++++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/http-server/Server.php b/http-server/Server.php index 35b298f4..2c3bdd09 100644 --- a/http-server/Server.php +++ b/http-server/Server.php @@ -50,9 +50,6 @@ class Server extends HttpService - /** @var ContainerInterface */ - #[Inject(ContainerInterface::class)] - public ContainerInterface $container; /** @@ -60,8 +57,6 @@ class Server extends HttpService */ public function init() { - $this->container->mapping(RequestInterface::class, Request::class); - $this->container->mapping(ResponseInterface::class, Response::class); } diff --git a/http-server/ServerCommand.php b/http-server/ServerCommand.php index fc1544a3..bb7c47ed 100644 --- a/http-server/ServerCommand.php +++ b/http-server/ServerCommand.php @@ -6,7 +6,12 @@ namespace Server; use Annotation\Inject; use Exception; +use Http\Constrict\Request; +use Http\Constrict\RequestInterface; +use Http\Constrict\Response; +use Http\Constrict\ResponseInterface; use Kiri\Abstracts\Config; +use Kiri\Di\ContainerInterface; use Kiri\Events\EventProvider; use Kiri\Exception\ConfigException; use Kiri\Kiri; @@ -41,6 +46,11 @@ class ServerCommand extends Command public EventProvider $eventProvider; + /** @var ContainerInterface */ + #[Inject(ContainerInterface::class)] + public ContainerInterface $container; + + /** * */ @@ -62,6 +72,9 @@ class ServerCommand extends Command public function execute(InputInterface $input, OutputInterface $output): int { try { + $this->container->mapping(RequestInterface::class, Request::class); + $this->container->mapping(ResponseInterface::class, Response::class); + $manager = Kiri::app()->getServer(); $manager->setDaemon((int)is_null($input->getOption('daemon'))); if (!in_array($input->getArgument('action'), self::ACTIONS)) {