Class RedirectRegexRule
- java.lang.Object
-
- org.eclipse.jetty.rewrite.handler.Rule
-
- org.eclipse.jetty.rewrite.handler.RegexRule
-
- org.eclipse.jetty.rewrite.handler.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 Redirectionstatus code set.Defaults to
302 Found
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.jetty.rewrite.handler.Rule
Rule.ApplyURI
-
-
Constructor Summary
Constructors Constructor Description RedirectRegexRule()RedirectRegexRule(String regex, String location)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected Stringapply(String target, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Matcher matcher)Apply this rule to the request/response pair.voidsetLocation(String location)voidsetReplacement(String replacement)Deprecated.voidsetStatusCode(int statusCode)Sets the redirect status code.StringtoString()Returns the redirect status code and replacement.-
Methods inherited from class org.eclipse.jetty.rewrite.handler.RegexRule
getRegex, matchAndApply, setRegex
-
Methods inherited from class org.eclipse.jetty.rewrite.handler.Rule
isHandling, isTerminating, setHandling, setTerminating
-
-
-
-
Field Detail
-
_location
protected String _location
-
-
Method Detail
-
setReplacement
@Deprecated public void setReplacement(String replacement)
Deprecated.
-
setLocation
public void setLocation(String location)
-
setStatusCode
public void setStatusCode(int statusCode)
Sets the redirect status code.- Parameters:
statusCode- the 3xx redirect status code
-
apply
protected String apply(String target, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Matcher matcher) throws IOException
Description copied from class:RegexRuleApply this rule to the request/response pair. Called byRegexRule.matchAndApply(String, HttpServletRequest, HttpServletResponse)if the regex matches.- Specified by:
applyin classRegexRule- Parameters:
target- field to attempt matchrequest- request objectresponse- response objectmatcher- The Regex matcher that matched the request (with capture groups available for replacement).- Returns:
- The target (possible updated).
- Throws:
IOException- exceptions dealing with operating on request or response objects
-
-