public function output($response)
    {
        // Set format
        switch ($this->format) {
            case 'json':
                $response = array_merge_recursive($response, $this->extra);
                $this->header('Content-type: application/json; charset=utf-8');
                $response = json_encode($response);

                // Replace string numbers for integers
                $response = preg_replace('/(")([0-9]+)(")/is', '\\2', $response);
                break;
            case 'html':
                $this->header('Content-type: text/html; charset=utf-8');
                $response = $this->html($response);
                break;
        }

        // Set cookies
        foreach ($this->cookies as $key => $value) {
            setcookie($key, $value, time() + 3600, '/');
        }

        // Set headers
        foreach ($this->headers as $header) {
            header($header);
        }

        // Return response
        echo $response;
        exit;
    }