Class RedirectRegexRule


public class RedirectRegexRule extends RegexRule

Issues a (3xx) redirect response whenever the rule finds a request path regular expression match

The replacement string may use $n to replace the nth capture group.

All redirects are part of the 3xx Redirection status code set.

Defaults to 302 Found.

  • Field Details

    • _location

      protected String _location
  • Constructor Details

    • RedirectRegexRule

      public RedirectRegexRule()
    • RedirectRegexRule

      public RedirectRegexRule(@Name("regex") String regex, @Name("location") String location)
  • Method Details

    • isTerminating

      public boolean isTerminating()
      Overrides:
      isTerminating in class Rule
      Returns:
      whether rules after this one are not invoked
    • getLocation

      public String getLocation()
    • setLocation

      public void setLocation(String location)
      Set the location to redirect..
      Parameters:
      location - the location to redirect.
    • getStatusCode

      public int getStatusCode()
    • setStatusCode

      public void setStatusCode(int statusCode)
    • apply

      protected Rule.Handler apply(Rule.Handler input, Matcher matcher) throws IOException
      Description copied from class: RegexRule

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

      Specified by:
      apply in class RegexRule
      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()
      Returns the redirect status code and replacement.
      Overrides:
      toString in class RegexRule