Class WebRequestPattensRule

java.lang.Object
io.microsphere.spring.web.rule.AbstractWebRequestRule<String>
io.microsphere.spring.web.rule.WebRequestPattensRule
All Implemented Interfaces:
WebRequestRule

public class WebRequestPattensRule extends AbstractWebRequestRule<String>
WebRequest Patterns WebRequestRule

A logical disjunction (' || ') request condition that matches a request against a set of URL path patterns.

In contrast to PathPatternsRequestCondition which uses parsed PathPatterns, this condition does String pattern matching via AntPathMatcher.

Since:
1.0.0
Author:
Mercy
See Also:
  • org.springframework.web.servlet.mvc.condition.PatternsRequestCondition
  • org.springframework.web.reactive.result.condition.PatternsRequestCondition
  • Constructor Details

    • WebRequestPattensRule

      public WebRequestPattensRule(String... patterns)
      Constructor with URL patterns which are prepended with "/" if necessary.
      Parameters:
      patterns - 0 or more URL patterns; no patterns results in an empty path "" mapping which matches all requests.
    • WebRequestPattensRule

      public WebRequestPattensRule(String[] patterns, boolean useTrailingSlashMatch, @Nullable org.springframework.util.PathMatcher pathMatcher)
      Variant of WebRequestPattensRule(String...) with a PathMatcher and flag for matching trailing slashes.
    • WebRequestPattensRule

      @Deprecated public WebRequestPattensRule(String[] patterns, @Nullable org.springframework.web.util.UrlPathHelper urlPathHelper, @Nullable org.springframework.util.PathMatcher pathMatcher, boolean useTrailingSlashMatch)
      Deprecated.
      Variant of WebRequestPattensRule(String...) with a UrlPathHelper and a PathMatcher, and whether to match trailing slashes.

      As of 5.3 the path is obtained through the static method UrlPathHelper.getResolvedLookupPath(jakarta.servlet.ServletRequest) and a UrlPathHelper does not need to be passed in. WebRequestPattensRule(String[], boolean, PathMatcher).

    • WebRequestPattensRule

      public WebRequestPattensRule(String[] patterns, @Nullable org.springframework.web.util.UrlPathHelper urlPathHelper, @Nullable org.springframework.util.PathMatcher pathMatcher, boolean useSuffixPatternMatch, boolean useTrailingSlashMatch)
      Variant of #PatternsRequestCondition(String...) with a UrlPathHelper and a PathMatcher, and flags for matching with suffixes and trailing slashes.

      As of 5.3 the path is obtained through the static method UrlPathHelper.getResolvedLookupPath(jakarta.servlet.ServletRequest) and a UrlPathHelper does not need to be passed in.

    • WebRequestPattensRule

      public WebRequestPattensRule(String[] patterns, @Nullable org.springframework.web.util.UrlPathHelper urlPathHelper, @Nullable org.springframework.util.PathMatcher pathMatcher, boolean useSuffixPatternMatch, boolean useTrailingSlashMatch, @Nullable List<String> fileExtensions)
      Variant of WebRequestPattensRule(String...) with a UrlPathHelper and a PathMatcher, and flags for matching with suffixes and trailing slashes, along with specific extensions.
      Parameters:
      patterns -
      urlPathHelper -
      pathMatcher -
      useSuffixPatternMatch -
      useTrailingSlashMatch -
      fileExtensions -
  • Method Details

    • getContent

      protected Collection<String> getContent()
      Description copied from class: AbstractWebRequestRule
      Return the discrete items a request condition is composed of.

      For example URL patterns, HTTP request methods, param expressions, etc.

      Specified by:
      getContent in class AbstractWebRequestRule<String>
      Returns:
      a collection of objects (never null)
    • getToStringInfix

      protected String getToStringInfix()
      Description copied from class: AbstractWebRequestRule
      The notation to use when printing discrete items of content.

      For example " || " for URL patterns or " && " for param expressions.

      Specified by:
      getToStringInfix in class AbstractWebRequestRule<String>
    • matches

      public boolean matches(org.springframework.web.context.request.NativeWebRequest request)
    • matches

      public boolean matches(String lookupPath)
    • getMatchingPatterns

      public List<String> getMatchingPatterns(String lookupPath)
    • getMatchingPattern

      @Nullable protected String getMatchingPattern(String pattern, String lookupPath)