private function getDispatcher($routes)
    {
        $verbs = self::$allHttpVerbs;
        $f = function (RouteCollector $collector) use ($routes, $verbs) {
            foreach ($routes as $pattern => $route) {
                if (is_array($route)) {
                    foreach ($route as $verb => $callback) {
                        $collector->addRoute(strtoupper($verb), $pattern, $callback);
                    }
                } else {
                    foreach ($verbs as $verb) {
                        $collector->addRoute($verb, $pattern, $route);
                    }
                }
            }
        };

        $options = $this->getOptions();
        $cacheData = array();
        if (isset($options[self::KEY_CACHE])) {
            $cacheData = (array)$options[self::KEY_CACHE];
        }

        if (empty($cacheData)) {
            return \FastRoute\simpleDispatcher($f);
        } else {
            return \FastRoute\cachedDispatcher($f, $cacheData);
        }
    }