public function __construct($mode = 'debug', $realm = 'Rest Server')
{
$this->mode = $mode;
$this->realm = $realm;
// Set the root
$dir = str_replace('\\', '/', dirname(str_replace($_SERVER['DOCUMENT_ROOT'], '', $_SERVER['SCRIPT_FILENAME'])));
if ($dir == '.') {
$dir = '/';
} else {
// add a slash at the beginning and end
if (substr($dir, -1) != '/') {
$dir .= '/';
}
if (substr($dir, 0, 1) != '/') {
$dir = '/' . $dir;
}
}
$this->root = $dir;
}