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 org.eclipse.jetty.rewrite.handler.Rule
Rule.Handler, Rule.HttpURIHandler
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Rule.Handler
apply
(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.boolean
Is 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 outputHandler
that applies the rule logic.void
setMatchQuery
(boolean flag) Enable or disable regex matching against URI path with query section present.void
Sets the regular expression to match with the request path.toString()
Methods inherited from class org.eclipse.jetty.rewrite.handler.Rule
isTerminating, setTerminating
-
Constructor Details
-
RegexRule
public RegexRule() -
RegexRule
-
-
Method Details
-
getRegex
Get the regular expression.- Returns:
- the regular expression
-
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:Rule
Tests whether the given input
Handler
(which wraps aRequest
) matches the rule, and if so returns an outputHandler
that applies the rule logic.If the input does not match,
null
is returned.- Specified by:
matchAndApply
in classRule
- Parameters:
input
- the inputHandler
that wraps theRequest
- Returns:
- an output
Handler
that wraps the inputHandler
, ornull
if 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 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
-