class_docstr: Router that performs longest prefix matches on incoming routes.
class_docstr_tok: ["Router","that","performs","longest","prefix","matches","on","incoming","routes","."]
docstr: Return the longest prefix match among existing routes for the route.
  Args:
      target_route: route to match against.
  Returns:
      (route, handle, is_cross_language) if found, else None.
docstr_tok: ["Return","the","longest","prefix","match","among","existing","routes","for","the","route",".","Args",":","target_route",":","route","to","match","against",".","Returns",":","(","route",",","handle",",","is_cross_language",")","if","found",",","else","None","."]
code: def match_route(
      self, target_route: str
  ) -> Optional[Tuple[str, RayServeHandle, bool]]:
      """Return the longest prefix match among existing routes for the route.
      Args:
          target_route: route to match against.
      Returns:
          (route, handle, is_cross_language) if found, else 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],
                      self.app_to_is_cross_language[endpoint.app],
                  )
  
      return None
  
file_path: ray/python/ray/serve/_private/proxy_router.py
imports: import logging
  from abc import ABC, abstractmethod
  from typing import Callable, Dict, List, Optional, Tuple
  from ray.serve._private.common import ApplicationName, EndpointInfo, EndpointTag, RequestProtocol
  from ray.serve._private.constants import RAY_SERVE_PROXY_PREFER_LOCAL_NODE_ROUTING, SERVE_LOGGER_NAME
  from ray.serve.handle import RayServeHandle
label_desc: Use image node_id 3 for calling the LongestPrefixRouter obj's underlying member method code with example usage: obj.match_route(target_route) and returns: None, route,  self,  self