Class RewriteRegexRule
java.lang.Object
org.eclipse.jetty.rewrite.handler.Rule
org.eclipse.jetty.rewrite.handler.RegexRule
org.eclipse.jetty.rewrite.handler.RewriteRegexRule
A rule to rewrite the path and query that match a regular expression pattern with a fixed string.
The replacement String follows standard Matcher.replaceAll(String)
behavior, including named groups
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jetty.rewrite.handler.Rule
Rule.Handler, Rule.HttpURIHandler
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapply
(Rule.Handler input, Matcher matcher) Invoked after the regular expression matched the URI path to apply the rule's logic.boolean
Is the input URI query added with replacement URI queryvoid
setAddQueries
(boolean flag) Set if input query should be preserved, and added together with replacement queryvoid
setReplacement
(String replacement) Whenever a match is found, it replaces with this value.toString()
Methods inherited from class org.eclipse.jetty.rewrite.handler.RegexRule
getRegex, isMatchQuery, matchAndApply, setMatchQuery, setRegex
Methods inherited from class org.eclipse.jetty.rewrite.handler.Rule
isTerminating, setTerminating
-
Constructor Details
-
RewriteRegexRule
public RewriteRegexRule() -
RewriteRegexRule
-
-
Method Details
-
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.
-
setReplacement
Whenever a match is found, it replaces with this value.- Parameters:
replacement
- the replacement string.
-
apply
Description copied from class:RegexRule
Invoked after the regular expression matched the URI path to apply the rule's logic.
- Specified by:
apply
in classRegexRule
- Parameters:
input
- the inputRequest
andHandler
matcher
- theMatcher
that matched the request path, with capture groups available for replacement.- Returns:
- the possibly wrapped
Request
andHandler
- Throws:
IOException
- if applying the rule failed
-
toString
-