public function setOutput($output, string $mime = "text/html")
    {
        if (
            !is_string($output) && !is_callable($output) 
            && !(is_object($output) && method_exists($output, '__toString'))
        )
        {
            throw new \InvalidArgumentException(
                "Output must be text, string-castable object or valid callback"
            );
        }
        $this->addMimeType($mime);
        $this->output[$mime] = $output;
        return $this;
    }