From a0c5e3a82d18d09f9f1e501bfab03fcf70796be5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Fri, 24 Sep 2021 18:08:40 +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-handler/Abstracts/Middleware.php | 4 ++++ http-handler/CoreMiddleware.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/http-handler/Abstracts/Middleware.php b/http-handler/Abstracts/Middleware.php index 5e681292..0ef5e1d5 100644 --- a/http-handler/Abstracts/Middleware.php +++ b/http-handler/Abstracts/Middleware.php @@ -13,4 +13,8 @@ use Server\Constrict\ResponseInterface; abstract class Middleware implements MiddlewareInterface { + + #[Inject(ResponseInterface::class)] + public ResponseInterface $response; + } diff --git a/http-handler/CoreMiddleware.php b/http-handler/CoreMiddleware.php index fdaa0a73..4fb4b33e 100644 --- a/http-handler/CoreMiddleware.php +++ b/http-handler/CoreMiddleware.php @@ -21,7 +21,7 @@ class CoreMiddleware extends Middleware public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { var_dump(get_called_class()); - $response = response()->withAccessControlAllowOrigin('*') + $this->response->withAccessControlAllowOrigin('*') ->withAccessControlRequestMethod($request->getAccessControlRequestMethod()) ->withAccessControlAllowHeaders($request->getAccessControlAllowHeaders());