public function route()
    {
        $this->Logger->debug("Request: {$this->Request->getFullURL()}");

        $uri = $this->Request->getAdjustedRequestURI();

//        $uri = $this->sanitizeURI($uri);

        $this->Logger->debug("Routing URI: {$uri}");



        $result = array();
        $qs = array_merge($_POST, $_GET);

        $routes = $this->routeService->findAll();

//        $regex = $this->compoundRegex(array_keys($routes));
//        error_log($regex);
//
//        if (! preg_match($regex, $uri, $matches)) {
//            $match = '';
//            error_log('no match');
//            exit;
//            return false;
//        }
//        $match = $matches[0];
//        error_log('match = '.$match);
//        exit;

        $this->Logger->debug("Testing Routes\n");

        foreach ((array)$routes as $test_uri => $nvps) {

            $this->Logger->debug("{$test_uri}");


            $m = null;
            $re = str_replace('/', '\/', $test_uri);
            $match = preg_match('/^' . $re . '$/i', $uri, $m);
            if ($match) {
                if (!empty($nvps) && is_array($nvps)) {
                    foreach ($nvps as $name => $value) {
                        foreach ($m as $n => $v) {
                            $value = str_replace('$'.$n, $v, $value);
                        }

                        foreach ($qs as $n => $v) {
                            if (is_scalar($v))
                                $value = str_replace('$'.$n, $v, $value);
                        }

                        $varparts = null;
                        if (preg_match("/(.+)\[(.+)\]/", $name, $varparts)) {
                            $result[$varparts[1]][$varparts[2]] = $value;
                        } else {
                            $result[$name] = $value;
                        }
                    }
                }

                foreach ($m as $n => $v)
                    if (is_int($n))
                        unset($m[$n]);

                $result = array_merge($m, $result);

                $this->Logger->debug('Routing result:');
                $this->Logger->debug($result);

                return $result;
            }
        }

        $this->checkRedirects();

        $this->Logger->debug("No routes matched.");

        return null;
    }