Class RegexRule
java.lang.Object
org.eclipse.jetty.rewrite.handler.Rule
org.eclipse.jetty.rewrite.handler.RegexRule
- Direct Known Subclasses:
HeaderRegexRule, RedirectRegexRule, RewriteRegexRule, TerminatingRegexRule
Abstract rule that uses the regular expression syntax for path pattern matching.
-
Nested Class Summary
Nested classes/interfaces inherited from class Rule
Rule.Handler, Rule.HttpURIHandler -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Rule.Handlerapply(Rule.Handler input, Matcher matcher) Invoked after the regular expression matched the URI path to apply the rule's logic.getRegex()Get the regular expression.booleanIs regex matching against URI path with query section present.matchAndApply(Rule.Handler input) Tests whether the given inputHandler(which wraps aRequest) matches the rule, and if so returns an outputHandlerthat applies the rule logic.voidsetMatchQuery(boolean flag) Enable or disable regex matching against URI path with query section present.voidSets the regular expression to match with the request path.toString()Methods inherited from class Rule
isTerminating, setTerminating
-
Constructor Details
-
RegexRule
public RegexRule() -
RegexRule
-
-
Method Details
-
getRegex
-
setRegex
Sets the regular expression to match with the request path.
- Parameters:
regex- the regular expression
-
isMatchQuery
public boolean isMatchQuery()Is regex matching against URI path with query section present.
- Returns:
- true to match against URI path with query (default), false to match only against URI path.
-
setMatchQuery
public void setMatchQuery(boolean flag) Enable or disable regex matching against URI path with query section present.
- Parameters:
flag- true to have regex match against URI path with query, false to have match against only URI path.
-
matchAndApply
Description copied from class:RuleTests whether the given input
Handler(which wraps aRequest) matches the rule, and if so returns an outputHandlerthat applies the rule logic.If the input does not match,
nullis returned.- Specified by:
matchAndApplyin classRule- Parameters:
input- the inputHandlerthat wraps theRequest- Returns:
- an output
Handlerthat wraps the inputHandler, ornullif the rule does not match - Throws:
IOException- if applying the rule fails
-
apply
Invoked after the regular expression matched the URI path to apply the rule's logic.
- 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
-