Class RedirectRegexRule


  • public class RedirectRegexRule
    extends RegexRule
    Issues a (3xx) Redirect response whenever the rule finds a match via regular expression.

    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

    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.eclipse.jetty.rewrite.handler.Rule

        Rule.ApplyURI
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String _location  
      • Fields inherited from class org.eclipse.jetty.rewrite.handler.RegexRule

        _regex
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      protected java.lang.String apply​(java.lang.String target, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.util.regex.Matcher matcher)
      Apply this rule to the request/response pair.
      void setLocation​(java.lang.String location)  
      void setReplacement​(java.lang.String replacement)
      Deprecated.
      void setStatusCode​(int statusCode)
      Sets the redirect status code.
      java.lang.String toString()
      Returns the redirect status code and replacement.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • _location

        protected java.lang.String _location
    • Constructor Detail

      • RedirectRegexRule

        public RedirectRegexRule()
      • RedirectRegexRule

        public RedirectRegexRule​(@Name("regex")
                                 java.lang.String regex,
                                 @Name("location")
                                 java.lang.String location)
    • Method Detail

      • setReplacement

        @Deprecated
        public void setReplacement​(java.lang.String replacement)
        Deprecated.
      • setLocation

        public void setLocation​(java.lang.String location)
      • setStatusCode

        public void setStatusCode​(int statusCode)
        Sets the redirect status code.
        Parameters:
        statusCode - the 3xx redirect status code
      • apply

        protected java.lang.String apply​(java.lang.String target,
                                         javax.servlet.http.HttpServletRequest request,
                                         javax.servlet.http.HttpServletResponse response,
                                         java.util.regex.Matcher matcher)
                                  throws java.io.IOException
        Description copied from class: RegexRule
        Apply this rule to the request/response pair. Called by RegexRule.matchAndApply(String, HttpServletRequest, HttpServletResponse) if the regex matches.
        Specified by:
        apply in class RegexRule
        Parameters:
        target - field to attempt match
        request - request object
        response - response object
        matcher - The Regex matcher that matched the request (with capture groups available for replacement).
        Returns:
        The target (possible updated).
        Throws:
        java.io.IOException - exceptions dealing with operating on request or response objects
      • toString

        public java.lang.String toString()
        Returns the redirect status code and replacement.
        Overrides:
        toString in class RegexRule