python/ray/serve/http_proxy.py
def match_route(
        self, target_route: str
    ) -> Tuple[Optional[str], Optional[RayServeHandle]]:
        """Return the longest prefix match among existing routes for the route.

        Args:
            target_route (str): route to match against.

        Returns:
            (matched_route (str), serve_handle (RayServeHandle)) if found,
            else (None, None).
        """

        for route in self.sorted_routes:
            if target_route.startswith(route):
                matched = False
                # If the route we matched on ends in a '/', then so does the
                # target route and this must be a match.
                if route.endswith("/"):
                    matched = True
                # If the route we matched on doesn't end in a '/', we need to
                # do another check to ensure that either this is an exact match
                # or the next character in the target route is a '/'. This is
                # to guard against the scenario where we have '/route' as a
                # prefix and there's a request to '/routesuffix'. In this case,
                # it should *not* be a match.
                elif len(target_route) == len(route) or target_route[len(route)] == "/":
                    matched = True

                if matched:
                    endpoint = self.route_info[route]
                    return route, self.handles[endpoint]

        return None, None
Return the longest prefix match among existing routes for the route.

        Args:
            target_route (str): route to match against.

        Returns:
            (matched_route (str), serve_handle (RayServeHandle)) if found,
            else (None, None).
        
Return the longest prefix match among existing routes for the route.
Return the longest prefix match among existing routes for the route .
def match_route(
        self, target_route: str
    ) -> Tuple[Optional[str], Optional[RayServeHandle]]:
        for route in self.sorted_routes:
            if target_route.startswith(route):
                matched = False
                if route.endswith("/"):
                    matched = True
                elif len(target_route) == len(route) or target_route[len(route)] == "/":
                    matched = True
                if matched:
                    endpoint = self.route_info[route]
                    return route, self.handles[endpoint]
        return None, None
def match_route ( self , target_route : str ) -> Tuple [ Optional [ str ] , Optional [ RayServeHandle ] ] : for route in self . sorted_routes : if target_route . startswith ( route ) : matched = False if route . endswith ( "/" ) : matched = True elif len ( target_route ) == len ( route ) or target_route [ len ( route ) ] == "/" : matched = True if matched : endpoint = self . route_info [ route ] return route , self . handles [ endpoint ] return None , None
Return the longest prefix match among existing routes for the route.
Return the longest prefix match among existing routes for the route .
"""Return the longest prefix match among existing routes for the route.

        Args:
            target_route (str): route to match against.

        Returns:
            (matched_route (str), serve_handle (RayServeHandle)) if found,
            else (None, None).
        """ # If the route we matched on ends in a '/', then so does the # target route and this must be a match. # If the route we matched on doesn't end in a '/', we need to # do another check to ensure that either this is an exact match # or the next character in the target route is a '/'. This is # to guard against the scenario where we have '/route' as a # prefix and there's a request to '/routesuffix'. In this case, # it should *not* be a match.
(matched_route (str), serve_handle (RayServeHandle)) if found,
else (None, None).
( matched_route ( str ) serve_handle ( RayServeHandle )) if found else ( None None ) .
self
target_route
str
route to match against.
route to match against .