protected function finalize($function)
    {
        $response = $this->container->get(self::RESPONSE);

        if (is_string($function) === true) {
            $stream = $response->getBody();

            $stream->write((string) $function);
        }

        $instanceof = $function instanceof ResponseInterface;

        return $instanceof ? $function : $response;
    }