Class RestConsumerContextPathMatcher

java.lang.Object
org.apache.camel.support.RestConsumerContextPathMatcher

public final class RestConsumerContextPathMatcher extends Object
A context path matcher when using rest-dsl that allows components to reuse the same matching logic.

The component should use the matchBestPath(String, String, List) with the request details and the matcher returns the best matched, or null if none could be determined.

The RestConsumerContextPathMatcher.ConsumerPath is used for the components to provide the details to the matcher.

  • Method Details

    • matchPath

      public static boolean matchPath(String requestPath, String consumerPath, boolean matchOnUriPrefix)
      Does the incoming request match the given consumer path (ignore case)
      Parameters:
      requestPath - the incoming request context path
      consumerPath - a consumer path
      matchOnUriPrefix - whether to use the matchOnPrefix option
      Returns:
      true if matched, false otherwise
    • matchBestPath

      public static <T> RestConsumerContextPathMatcher.ConsumerPath<T> matchBestPath(String requestMethod, String requestPath, List<RestConsumerContextPathMatcher.ConsumerPath<T>> consumerPaths)
      Finds the best matching of the list of consumer paths that should service the incoming request.
      Parameters:
      requestMethod - the incoming request HTTP method
      requestPath - the incoming request context path
      consumerPaths - the list of consumer context path details
      Returns:
      the best matched consumer, or null if none could be determined.
    • register

      public static void register(String consumerPath)
      Pre-compiled consumer path for wildcard match
      Parameters:
      consumerPath - a consumer path
    • unRegister

      public static void unRegister(String consumerPath)
      if the rest consumer is removed, we also remove pattern cache.
      Parameters:
      consumerPath - a consumer path