getMethod() === 'HEAD') { return $this->response->withBody(new Stream()); } if ($result instanceof ResponseInterface) { return $result; } if (is_object($result)) { return $this->response->withBody(new Stream('[object]')); } if (is_array($result)) { return $this->response->withBody(new Stream(json_encode($result, JSON_UNESCAPED_UNICODE))); } else { return $this->response->withBody(new Stream((string)$result)); } } }