Class UrlPatternMatcher

java.lang.Object
io.quarkiverse.openapi.generator.providers.UrlPatternMatcher

public class UrlPatternMatcher extends Object
PathPatternMatcher leverages Regex Pattern to represent a parameterized URL. Parameters within the URL are denoted by curly braces '{}' with the parameter name contained within (e.g. '{userid}').

Parameter names must be formed of word characters (e.g. A-Z, a-z, 0-9, '_').

An optional format parameter following a dot ('.') may be added to the end. While it could be named any valid parameter name, RestExpress offers special handling (e.g. within the Request, etc.) if it's named 'format'.

Note that the format specifier allows only word characters and percent-encoded characters.

URL Pattern examples:

  • /api/search.{format}
  • /api/search/users/{userid}.{format}
  • /api/{version}/search/users/{userid}

RestExpress parses URI paths which is described in the URI Generic Syntax IETF RFC 3986 specification, section 3.3 (http://tools.ietf.org/html/rfc3986#section-3.3). RestExpress parses paths into segments separated by slashes ("/"), the segments of which are composed of unreserved, percent encoded, sub-delimiters, colon (":") or ampersand ("@"), each of which are defined below (from the spec):

pct-encoded = "%" HEXDIG HEXDIG

unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
reserved = gen-delims / sub-delims
gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@"
sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "=" *

In other words, RestExpress accepts path segments containing: [A-Z] [a-z] [0-9] % - . _ ~ ! $ & ' ( ) * + , ; = : @

RestExpress also accepts square brackets ('[' and ']'), but this is deprecated and not recommended.

Since:
Apr 28, 2010
Author:
toddf
See Also:
  • Constructor Details

    • UrlPatternMatcher

      public UrlPatternMatcher(String pattern)
      Parameters:
      pattern -
  • Method Details

    • matches

      public boolean matches(String url)
      Test the given URL against the underlying pattern to determine if it matches, returning a boolean to reflect the outcome.
      Parameters:
      url - an URL string with or without query string.
      Returns:
      true if the given URL matches the underlying pattern. Otherwise false.