Test all routes until any of them matches

@throws RouteNotFoundException if the route doesn't match with any of the registered routes
169291
public function route()
    {
        foreach ($this->routes as $route) {
            if ($route->matches($this->path)) {
                return $route->exec();
            }
        }

        throw new RouteNotFoundException("No routes matching {$this->path}");
    }
131358
public function matchRoute()
	{

		//check if this route key exists
		$RouteMatch = (ArrayHelper::KeyExists($this->UrlParserObjectInstance->getController(), $this->definedRoutesArray)->get()) ? true : false;

		//a matching route was found, set params and return true
		if($RouteMatch)
		{
			//set the value of the routeName
			$this->routeName = $this->UrlParserObjectInstance->getController();

			//get metaData for this route
			$this->routeMetaData = $this->definedRoutesArray[$this->UrlParserObjectInstance->getController()];

			//return true
			return true;

		}

		//not matching route was found, return fasle
		else{

			//return false
			return false;

		}

	}
1193521
protected function checkFallbacks($routes, $httpMethod)
    {
        $additional = array(Route::ANY);

        if ($httpMethod === Route::HEAD) {
            $additional[] = Route::GET;
        }

        foreach ($additional as $method) {
            if (isset($routes[$method])) {
                return $method;
            }
        }

        $this->matchedRoute = $routes;

        throw new HttpMethodNotAllowedException('Allow: ' . implode(', ', array_keys($routes)));
    }
371630
private function createRoute(): void
    {
        $this->virtualArgs = [];
        $this->realArgs = \explode('/', $this->url);

        do {
            if ($this->setMainController(
                $this->routingBasePath . implode('/', $this->realArgs)
            )) return;

            array_unshift($this->virtualArgs, array_pop($this->realArgs));
        }
        while (count($this->realArgs) > 0);

        throw new NoControllerFoundException();
    }
913908
public function match(
       ServerRequestInterface &$request,
       RouteInterface $route): bool
   {
        if ($this->matchAction($request, $route)
         && $this->matchPath($request, $route)) {
            $request = $request->withAttribute("route", $route);
            return true;
        }
        return false;
   }
894690
protected function check(array $routes, $request, $includingMethod = true)
    {
        return Arr::first($routes, function ($key, $route) use ($request, $includingMethod)
        {
            return $route->matches($request, $includingMethod);
        });
    }
580994
protected function matchAgainstRoutes(array $routes, $request, $includingMethod = true)
    {
        [$fallbacks, $routes] = collect($routes)->partition(function ($route) {
            return $route->isFallback;
        });

        return $routes->merge($fallbacks)->first(function ($value) use ($request, $includingMethod) {
            return $value->matches($request, $includingMethod);
        });
    }
595544
protected function matchCache()
    {
        // check if we can find a match in cache
        // check if a cache exists
        if ($this->cache instanceof Cache) {
            // check if we have any routes saved in cache
            if ($cachedRoutes = $this->cache->get('routeMiddlewareRoutes')) {
                // check if the requested uri can be found in the cache
                if (isset($cachedRoutes[$this->requestUri])) {

                    // check if endpoint class exists
                    if (!$this->endpointExists($cachedRoutes[$this->requestUri]['matchedEndpoint'])) {
                        throw new NotFound();
                    }

                    if (!$this->endpointMethodExists(
                        $cachedRoutes[$this->requestUri]['matchedEndpoint'],
                        $this->requestMethod
                    )) {
                        // route found but method can't be found
                        throw new MethodNotAllowed();
                    }

                    // match found, set info
                    $this->matchedRoute = $cachedRoutes[$this->requestUri]['matchedRoute'];
                    $this->matchedEndpoint = $cachedRoutes[$this->requestUri]['matchedEndpoint'];
                    $this->matchedMethod  = $this->requestMethod;
                    $this->params  = (isset($cachedRoutes[$this->requestUri]['params'])) ?
                        $cachedRoutes[$this->requestUri]['params'] : [];

                    // no need to look for more
                    return true;
                }
            }
        }

        return false;
    }
113931
public function route()
    {
        $this->routes->rewind();
        while ($this->routes->valid()) {
            $route = $this->routes->current();
            if ($route->run()) {
                return;
            }
            $this->routes->next();
        }

        throw new \RuntimeException("FlexPress router: No route found - please make sure you have setup routes.");

    }
3551
protected function isMatchingRouteName()
    {
        return $this->getCurrentRouteName() == $this->getRouteName() || array_key_exists($this->getCurrentRouteName(), $this->getAliasRouteNames());
    }
981379
function(routes, callback) {
    var newRoutes = {};

    // Add a route.
    newRoutes['/test'] = {
      callback: function(request, response) {
        response.send('Testing!');
      }
    };

    // Add another route.
    newRoutes['/test-altering'] = {
      callback: function(request, response) {
        response.send('Testing!');
      }
    };

    callback(null, newRoutes);
  }
770831
public function match($pathinfo)
    {
        $routes = array();
        $this->debug(sprintf('match: Matching %s', $pathinfo));

        foreach ($this->matchers as $matcher) {
            try {
                $routes = $matcher->match($pathinfo);
                break;
            } catch (ResourceNotFoundException $e) {
            } catch (MethodNotAllowedException $e) {
            }
        }

        if (!isset($routes['_route']) || !isset($routes['_controller'])) {
            $mesg = 'match: No Routes Found.';
            $this->alert($mesg);
            throw new RoutingException($mesg);
        }

        $this->debug(sprintf('match: Route matched %s', $routes['_route']));

        return($routes);
    }
1290472
public function filter()
    {
        $requestUrl = $this->application->request->getQuery('url', '/');
        $requestMethod = $this->application->request->getMethod();
        $event = new Route([
            'router' => $this,
            'application' => $this->application,
            'request' => $this->application->request
        ]);
        $this->_application->getEventManager()
            ->trigger(Route::BEFORE_ROUTE, $this, $event);
        $options = $this->getService()->match($requestUrl, $requestMethod);
        if ($options == false) {
            throw new RouterException(
                "No route was found for the given request URL."
            );
        }
        // Route match, add the extension
        $cfg = $this->application->getContainer()->get('configuration');


        $routerInfo = new RouteInfo($options);
        $routerInfo->setConfiguration($cfg)
            ->setTarget($options['target']);

        $extension = $this->application->getRequest()
            ->getQuery('extension');

        if (strlen($extension) < 1) {
            $extension = $cfg->get('router.extension', 'html');
        }
        $routerInfo->extension = $extension;

        $event->routeInfo = $routerInfo;
        $this->_application->getEventManager()
            ->trigger(Route::AFTER_ROUTE, $this, $event);
        return $event->routeInfo;
    }
516673
public function verifyRoute(): void
    {
        $this->context->waitUntil($this->defaultTimeout, function () {
            return false !== strpos($this->context->getSession()->getCurrentUrl(), $this->route);
        });
    }
1032040
public boolean anyMatched(String[] requestPathTokens) {
		Map<String, String> pathParams = new HashMap<>();
		for (PathPattern pattern : routes.keySet()) {
			if (pattern.match(requestPathTokens, pathParams)) {
				return true;
			}

			// Reset for the next loop
			pathParams.clear();
		}

		return false;
	}
282509
private function matchExact(): bool
    {
        foreach ($this->routesExact as $route) {
            if ($this->uri === $route['u']) { // compare the current URI array to this route URI array
                $this->control = $route['c']; // set control or this exact match

                return true; // exact match found
            }
        }

        return false; // exact match not found
    }
1256582
private function buildValidRoute(Route $route): void
    {
        //add to route array the passed uri for param check when call
        $matches = $this->routeMatches;

        //route match and there is a subpattern with action
        if (\count($matches) > 1) {
            //assume that subpattern rapresent action
            $route->action = $matches[1];

            //url clean
            $route->url = \preg_replace('`\([0-9A-Za-z\|]++\)`', $matches[1], $route->url);
        }

        $route->param = $this->buildParam($route);

        $this->route = $route;
    }