This commit is contained in:
as2252258@163.com
2021-08-05 00:57:45 +08:00
parent 1d68177cb9
commit 8b638abf13
3 changed files with 7 additions and 12 deletions
+3 -7
View File
@@ -161,7 +161,7 @@ class Response extends HttpService implements ResponseInterface
* @return Response * @return Response
* @throws Exception * @throws Exception
*/ */
public function getBuilder(mixed $data, SResponse $response = null): static public function getBuilder(mixed $data, SResponse $response = null): ResponseInterface
{ {
if ($response != null) { if ($response != null) {
$this->configure($response); $this->configure($response);
@@ -195,14 +195,10 @@ class Response extends HttpService implements ResponseInterface
/** /**
* @param mixed $content * @param mixed $content
* @return Response|\Server\Constrict\Response * @return ResponseInterface
*/ */
public function setContent(mixed $content): Response|\Server\Constrict\Response public function setContent(mixed $content): ResponseInterface
{ {
// if ($content instanceof \Server\Constrict\Response
// || $content instanceof Response) {
// return $content;
// }
$this->endData = $content; $this->endData = $content;
return $this; return $this;
} }
+2 -2
View File
@@ -17,9 +17,9 @@ class ExceptionHandlerDispatcher implements ExceptionHandlerInterface
/** /**
* @param Throwable $exception * @param Throwable $exception
* @param CResponse $response * @param CResponse $response
* @return CResponse|\HttpServer\Http\Response * @return ResponseInterface
*/ */
public function emit(Throwable $exception, Response $response): Response|\HttpServer\Http\Response public function emit(Throwable $exception, Response $response): ResponseInterface
{ {
if ($exception->getCode() == 404) { if ($exception->getCode() == 404) {
return $response->setContent($exception->getMessage()) return $response->setContent($exception->getMessage())
+2 -3
View File
@@ -2,7 +2,6 @@
namespace Server; namespace Server;
use HttpServer\Http\Response as SResponse;
use Server\Constrict\Response; use Server\Constrict\Response;
use Throwable; use Throwable;
@@ -16,8 +15,8 @@ interface ExceptionHandlerInterface
/** /**
* @param Throwable $exception * @param Throwable $exception
* @param Response $response * @param Response $response
* @return Response|SResponse * @return ResponseInterface
*/ */
public function emit(Throwable $exception, Response $response): Response|SResponse; public function emit(Throwable $exception, Response $response): ResponseInterface;
} }