From ec483b6c691be7bdc7cb40f9c8aed3638f3c2140 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Tue, 17 Oct 2023 17:01:18 +0800 Subject: [PATCH] eee --- src/Format/ArrayFormat.php | 6 ++---- src/Format/MixedFormat.php | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Format/ArrayFormat.php b/src/Format/ArrayFormat.php index 6dc4a70..f995501 100644 --- a/src/Format/ArrayFormat.php +++ b/src/Format/ArrayFormat.php @@ -3,7 +3,6 @@ namespace Kiri\Router\Format; use Kiri\Router\Constrict\Stream; -use Kiri\Router\ContentType; use Psr\Http\Message\ResponseInterface; class ArrayFormat implements IFormat @@ -16,9 +15,8 @@ class ArrayFormat implements IFormat */ public function call($result): ResponseInterface { - $result = json_encode($result); - - return \response()->withBody(new Stream(json_encode($result, JSON_UNESCAPED_UNICODE))); + $result = json_encode($result, JSON_UNESCAPED_UNICODE); + return \response()->withBody(new Stream($result)); } diff --git a/src/Format/MixedFormat.php b/src/Format/MixedFormat.php index b141d9e..1d65d7a 100644 --- a/src/Format/MixedFormat.php +++ b/src/Format/MixedFormat.php @@ -22,7 +22,7 @@ class MixedFormat implements IFormat if (is_array($result)) { return \response()->withContentType(ContentType::JSON)->withBody(new Stream(json_encode($result, JSON_UNESCAPED_UNICODE))); } else { - return \response()->withBody(new Stream($result)); + return \response()->withBody(new Stream((string)$result)); } }