Class RedirectRegexRule
java.lang.Object
org.eclipse.jetty.rewrite.handler.Rule
org.eclipse.jetty.rewrite.handler.RegexRule
org.eclipse.jetty.rewrite.handler.RedirectRegexRule
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class Rule
Rule.Handler, Rule.HttpURIHandler -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Rule.Handlerapply(Rule.Handler input, Matcher matcher) Invoked after the regular expression matched the URI path to apply the rule's logic.intbooleanIs the input URI query added with replacement URI querybooleanvoidsetAddQueries(boolean flag) Set if input query should be preserved, and added together with replacement queryvoidsetLocation(String location) Set the location to redirect.voidsetStatusCode(int statusCode) toString()Returns the redirect status code and replacement.Methods inherited from class RegexRule
getRegex, isMatchQuery, matchAndApply, setMatchQuery, setRegexMethods inherited from class Rule
setTerminating
-
Field Details
-
_location
-
-
Constructor Details
-
RedirectRegexRule
public RedirectRegexRule() -
RedirectRegexRule
-
-
Method Details
-
isTerminating
public boolean isTerminating()- Overrides:
isTerminatingin classRule- Returns:
- whether rules after this one are not invoked
-
getLocation
-
setLocation
Set the location to redirect.- Parameters:
location- the location to redirect.
-
isAddQueries
public boolean isAddQueries()Is the input URI query added with replacement URI query
- Returns:
- true to add input query with replacement query.
-
setAddQueries
public void setAddQueries(boolean flag) Set if input query should be preserved, and added together with replacement query
This is especially useful when used in combination with a disabled
RegexRule.setMatchQuery(boolean)- Parameters:
flag- true to have input query added with replacement query, false (default) to have query from input or output just be treated as a string, and not merged.
-
getStatusCode
public int getStatusCode() -
setStatusCode
public void setStatusCode(int statusCode) -
apply
Description copied from class:RegexRuleInvoked after the regular expression matched the URI path to apply the rule's logic.
- Specified by:
applyin classRegexRule- Parameters:
input- the inputRequestandHandlermatcher- theMatcherthat matched the request path, with capture groups available for replacement.- Returns:
- the possibly wrapped
RequestandHandler - Throws:
IOException- if applying the rule failed
-
toString
-