diff --git a/src/Handler.php b/src/Handler.php index 55f6e3a..da7b362 100644 --- a/src/Handler.php +++ b/src/Handler.php @@ -99,11 +99,13 @@ class Handler implements RequestHandlerInterface return $result; } if (is_object($result)) { - $result = '[object]'; - } else if (is_array($result)) { - $result = json_encode($result, JSON_UNESCAPED_UNICODE); + return \response()->withBody(new Stream('[object]')); + } + 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($result)); } }