matchRequest

@param Request $request

@return MatchContext
12385
public function matchRequest(Request $request, RouteCollectionInterface $routes)
    {
        $path   = $request->getPath();
        $filtered = $this->filterByMethodAndScheme($routes, $request);

        if ($filtered instanceof CachedCollectionInterface && 0 !== count($r = $route->findByStaticPath($path))) {
            $filtered = $r;
        }

        $nomatch = array_diff_key($routes->all(), $filtered->all());

        foreach ($filtered->all() as $name => $route) {
            $rctx = $route->getContext();

            // does it match host?
            if (!$this->matchHost($rctx, $request, $route->getHost())) {
                $nomatch[$name] = $route;
                continue;
            }

            // does it match static path?
            if (0 !== strpos($path, $rctx->getStaticPath())) {
                continue;
            }

            // does it match pattern described on the route?
            if ((bool)preg_match_all($rctx->getRegex(), $path, $matches)) {
                $vars    = $this->getMatchedVars($route, $matches);
                $handler = $route->getHandler();

                return new MatchContext(self::MATCH, $name, $request, $handler, $vars);
            }

            $nomatch[$name] = $route;
        }

        return new MatchContext($this->getMatchFailureReason($nomatch, $request), null, $request, null);
    }
161085
private function matchRoute(ServerRequestInterface $request) : RouterMatch
    {
        $this->eventDispatcher->dispatch(new EventBeforeAppMatchingRoute($request));
        try {
            $routerMatch = $this->router->match($request);
        } catch (\Throwable $e) {
            $statusCode = 404;
            $message = "$statusCode: Router could not match request path {$request->getUri()->getPath()}";
            throw new HttpException($statusCode, $message, null, $e);
        }
        $this->eventDispatcher->dispatch(new EventAfterAppMatchingRoute($request, $routerMatch));
        return $routerMatch;
    }
1150199
public function matchRequest(SymfonyRequest $request)
    {
        $laravelRequest = LaravelRequest::createFromBase($request);
        $route = $this->findRoute($laravelRequest);
        $route->setParameter('_module', $this->moduleName);

        return $route;
    }
224465
public function matchRequest(Request $request)
    {
        $defaultSiteroot = null;

        $hostname = $request->getHost();

        foreach ($this->siterootManager->findAll() as $siteroot) {
            foreach ($siteroot->getUrls() as $siterootUrl) {
                $siterootHostname = $siterootUrl->getHostname();
                if ($siterootHostname === $hostname) {
                    return $siteroot;
                }
                if (isset($this->urlMappings[$siterootHostname])) {
                    if (in_array($hostname, $this->urlMappings[$siterootHostname])) {
                        return $siteroot;
                    }
                }
                if ($siterootHostname === $hostname) {
                    return $siteroot;
                }
                if ($siteroot->isDefault()) {
                    $defaultSiteroot = $siteroot;
                }
            }
        }

        if ($defaultSiteroot) {
            return $defaultSiteroot;
        }

        return null;
    }
1222044
public function match(Request $request)
	{
		foreach ($this->routes->filterByMethod($request->getMethod()) as $route)
		{
			if ($route->isMatch($request->getPathInfo()))
			{
				return $route;
			}
		}

		return null;
	}
61288
public function matches(Route $route, Request $request)
    {
        $regex = $route->getCompiled()->getRegex();

        if (str_contains($request->getRequestUri(), '/wp-admin')) {
            return preg_match(str_replace('$#s', '(?:&.+)?$#s', $regex), rawurldecode($request->getRequestUri()));
        }

        $path = $request->path() == '/' ? '/' : '/' . $request->path();

        return preg_match($regex, rawurldecode($path));
    }
799728
private function match($request)
    {
        $route = $this->router->match(
            $request->getUri()->getPath(),
            $request->getMethod()
        );
        if (!$route) {
            // not matched. dispatch the next middleware.
            return $this->next ? $this->next->__invoke($request) : null;
        }
        return $this->dispatch($request, $route);
    }
953940
protected function getRouteMatch(RequestInterface $request) : Match
	{
		/** @var Router $router */
		$router = $this->dependencyContainer->get('fuel.application.router');
		$match = $router->translate($request->getUri()->getPath(), $request->getMethod());

		return $match;
	}
908012
public function execute (Request $request)
		{
			foreach ($this->routes as $route) {
				if ($route->isValid($request)) {
					return $route->execute($request);
				}
			}

			throw new NoMatchingRouteException('No matching route found.');
		}
157154
public function match( Request $request )
	{
		$routes = $this->get( $request->getMethod() );

		// First, we will see if we can find a matching route for this current request
		// method. If we can, great, we can just return it so that it can be called
		// by the consumer. Otherwise we will check for routes with another verb.
		$route = $this->check( $routes, $request );

		if ( !is_null( $route ) )
		{
			return $route->bind( $request );
		}

		// If no route was found we will now check if a matching route is specified by
		// another HTTP verb. If it is we will need to throw a MethodNotAllowed and
		// inform the user agent of which HTTP verb it should use for this route.
		$others = $this->checkForAlternateVerbs( $request );

		if ( count( $others ) > 0 )
		{
			return $this->getRouteForMethods( $request, $others );
		}

		throw new NotFoundHttpException;
	}
556327
protected function getFiltersFromRequest(Request $request)
    {
        return $this->extractValues($this->getValuesFromRequest($request), $this->getFilterPrefix());
    }
1307481
protected function matchRequest(array $match, Request $request) : bool
    {
        if (!$request->is(trim($match['path'], '/'))) {
            return false;
        }

        $method = collect($match['method'])->filter()->map(function ($method) {
            return strtoupper($method);
        });

        return $method->isEmpty() || $method->contains($request->method());
    }
1176554
public function matchesRequest()
    {
        return Collection::make($this->config->get('matchingData'))->diffAssoc($this->event)->isEmpty();
    }
19216
public function match(RequestInterface $request)
    {
        return (
            $this->matchSchema($request->schema()) &&
            $this->matchMethods($request->method()) &&
            $this->matchHost($request->host()) &&
            $this->matchPath($request->path())
        );
    }
1074805
public function matchRequest(Request $request)
    {
        $requestUrl = $request->getRouteURL();
        $requestMethod = $request->getMethod();

        if (empty($this->routes)) {
            $routeFile = basePath('app/Routes/web.php');
            if (file_exists($routeFile)) {
                /** @noinspection PhpIncludeInspection */
                require_once $routeFile;
            } else {
                throw new Exception("Route definition file $routeFile does not exist");
            }
        }

        $params = array();
        foreach ($this->routes as $handler) {
            $methods = $handler->getHttpMethod();
            $route = $handler->getRouteURI();

            $method_match = (stripos($methods, $requestMethod) !== false);

            // Method did not match, continue to next route.
            if (!$method_match) {
                continue;
            }

            if ($route === '*') {
                // * wildcard (matches all)
                $match = true;
            } elseif (isset($route[0]) && $route[0] === '@') {
                // @ regex delimiter
                $pattern = '`' . substr($route, 1) . '`u';
                $match = preg_match($pattern, $requestUrl, $params) === 1;
            } elseif (($position = strpos($route, '[')) === false) {
                // No params in url, do string comparison
                $match = strcmp($requestUrl, $route) === 0;
            } else {
                // Compare longest non-param string with url
                if (strncmp($requestUrl, $route, $position) !== 0) {
                    continue;
                }
                $regex = $this->compileRoute($route);
                $match = preg_match($regex, $requestUrl, $params) === 1;
            }

            if ($match) {
                if ($params) {
                    foreach ($params as $key => $value) {
                        if (is_numeric($key)) {
                            unset($params[$key]);
                        }
                    }
                }
                $handler->setParameters($params);
                $handler->lock();
                $request->setRoute($handler);

                return $handler;
            }
        }

        return false;
    }
433980
public function matchesRequest()
    {
        return $this->event->get('token') === $this->config->get('token') && $this->event->get('type') === 'MESSAGE';
    }
414485
public static function route(Http\Request $request)
    {
        $path = $request->REQUEST_URI;
        $key = $request->getMethod().'@'.$path;
        $keyAny = 'ANY@'.$path;

        $matchedRoute = null;
        $matchedScore = 0;

        if (isset(self::$routes[$key])) {
            $matchedRoute = self::$routes[$key];
        } elseif (isset(self::$routes[$keyAny])) {
            $matchedRoute = self::$routes[$keyAny];
        } else {
            foreach (self::$routes as $key2 => $route) {
                if ($route->getMethod() != 'ANY' && $route->getMethod() != $request->getMethod()) {
                    continue;
                }

                $score = $route->getScore($path, $request->getMethod());
                if ($score > $matchedScore) {
                    $matchedRoute = $route;
                    $matchedScore = $score;
                }
            }
        }

        if ($matchedRoute) {
            $matchedRoute->setUrl($path);
        } elseif (self::$_404route) {
            $matchedRoute = self::$_404route;
        } else {
            throw new Exceptions\RouteException('Route not found');
        }
        return $matchedRoute;
    }