private function cleanHostName(ServerRequestInterface $request)
    {

        if (is_null($this->baseHost)) {
            $hostname = $request->getUri()->getHost();
        } else {
            $hostname = str_replace($this->baseHost, "", $request->getUri()->getHost());
        }

        if (substr($hostname, -1) == ".") {
            $hostname = substr($hostname, 0, -1);
        }

        return $hostname;
    }