public function handleRoute($environment = null)
    {
        if (null === $environment) {
            $environment = PHP_SAPI;
        }

        switch ($environment) {
            case 'cli':
            case 'phpdbg':
                $components = empty($_SERVER['argv']) ? array() : $_SERVER['argv'];
                return $this->handleCliRoute($components).PHP_EOL;
            default:
                $queryPos = strpos($_SERVER['REQUEST_URI'], '?');
                $path = (false === $queryPos) ? $_SERVER['REQUEST_URI'] : substr($_SERVER['REQUEST_URI'], 0, $queryPos);
                return $this->handleHttpRoute(
                    $path,
                    $_GET,
                    $_POST,
                    isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET'
                );
        }
    }