Class RegexRule

java.lang.Object
org.eclipse.jetty.rewrite.handler.Rule
org.eclipse.jetty.rewrite.handler.RegexRule
Direct Known Subclasses:
HeaderRegexRule, RedirectRegexRule, RewriteRegexRule, TerminatingRegexRule

public abstract class RegexRule extends Rule

Abstract rule that uses the regular expression syntax for path pattern matching.

  • Constructor Details

    • RegexRule

      public RegexRule()
    • RegexRule

      public RegexRule(String pattern)
  • Method Details

    • getRegex

      public String getRegex()
      Get the regular expression.
      Returns:
      the regular expression
    • setRegex

      public void setRegex(String regex)

      Sets the regular expression to match with the request path.

      Parameters:
      regex - the regular expression
    • matchAndApply

      public Rule.Handler matchAndApply(Rule.Handler input) throws IOException
      Description copied from class: Rule

      Tests whether the given input Handler (which wraps a Request) matches the rule, and if so returns an output Handler that applies the rule logic.

      If the input does not match, null is returned.

      Specified by:
      matchAndApply in class Rule
      Parameters:
      input - the input Handler that wraps the Request
      Returns:
      an output Handler that wraps the input Handler, or null if the rule does not match
      Throws:
      IOException - if applying the rule fails
    • apply

      protected abstract Rule.Handler apply(Rule.Handler input, Matcher matcher) throws IOException

      Invoked after the regular expression matched the URI path to apply the rule's logic.

      Parameters:
      input - the input Request and Handler
      matcher - the Matcher that matched the request path, with capture groups available for replacement.
      Returns:
      the possibly wrapped Request and Handler
      Throws:
      IOException - if applying the rule failed
    • toString

      public String toString()
      Overrides:
      toString in class Rule