Class RuleContainer
java.lang.Object
org.eclipse.jetty.rewrite.handler.Rule
org.eclipse.jetty.rewrite.handler.RuleContainer
- All Implemented Interfaces:
Dumpable
- Direct Known Subclasses:
RewriteCustomizer
,VirtualHostRuleContainer
Base container to group rules. Can be extended so that the contained rules
will only be applied under certain conditions
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jetty.rewrite.handler.Rule
Rule.ApplyURI
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
protected String
protected boolean
protected boolean
protected Rule[]
static final String
Fields inherited from class org.eclipse.jetty.rewrite.handler.Rule
_handling, _terminating
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a Ruleprotected String
apply
(String target, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Process the contained rules (called by matchAndApply)void
dump
(Appendable out, String indent) Dump this object (and children) into an Appendable using the provided indent after any new lines.Rule[]
getRules()
Returns the list of rules.boolean
boolean
matchAndApply
(String target, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Process the contained rulesvoid
setOriginalPathAttribute
(String originalPathAttribte) void
setRewritePathInfo
(boolean rewritePathInfo) void
setRewriteRequestURI
(boolean rewriteRequestURI) void
Assigns the rules to process.Methods inherited from class org.eclipse.jetty.rewrite.handler.Rule
isHandling, isTerminating, setHandling, setTerminating, toString
-
Field Details
-
ORIGINAL_QUERYSTRING_ATTRIBUTE_SUFFIX
- See Also:
-
_rules
-
_originalPathAttribute
-
_originalQueryStringAttribute
-
_rewriteRequestURI
protected boolean _rewriteRequestURI -
_rewritePathInfo
protected boolean _rewritePathInfo
-
-
Constructor Details
-
RuleContainer
public RuleContainer()
-
-
Method Details
-
getRules
Returns the list of rules.- Returns:
- an array of
Rule
.
-
setRules
Assigns the rules to process.- Parameters:
rules
- an array ofRule
.
-
addRule
Add a Rule- Parameters:
rule
- The rule to add to the end of the rules array
-
isRewriteRequestURI
public boolean isRewriteRequestURI()- Returns:
- the rewriteRequestURI If true, this handler will rewrite the value
returned by
HttpServletRequest.getRequestURI()
.
-
setRewriteRequestURI
public void setRewriteRequestURI(boolean rewriteRequestURI) - Parameters:
rewriteRequestURI
- true if this handler will rewrite the value returned byHttpServletRequest.getRequestURI()
.
-
isRewritePathInfo
public boolean isRewritePathInfo()- Returns:
- true if this handler will rewrite the value
returned by
HttpServletRequest.getPathInfo()
.
-
setRewritePathInfo
public void setRewritePathInfo(boolean rewritePathInfo) - Parameters:
rewritePathInfo
- true if this handler will rewrite the value returned byHttpServletRequest.getPathInfo()
.
-
getOriginalPathAttribute
- Returns:
- the originalPathAttribte. If non null, this string will be used as the attribute name to store the original request path.
-
setOriginalPathAttribute
- Parameters:
originalPathAttribte
- If non null, this string will be used as the attribute name to store the original request path.
-
matchAndApply
public String matchAndApply(String target, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws IOException Process the contained rules- Specified by:
matchAndApply
in classRule
- Parameters:
target
- target field to pass on to the contained rulesrequest
- request object to pass on to the contained rulesresponse
- response object to pass on to the contained rules- Returns:
- The new target if the rule has matched, else null
- Throws:
IOException
- if unable to match the rule
-
apply
protected String apply(String target, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws IOException Process the contained rules (called by matchAndApply)- Parameters:
target
- target field to pass on to the contained rulesrequest
- request object to pass on to the contained rulesresponse
- response object to pass on to the contained rules- Returns:
- the target
- Throws:
IOException
- if unable to apply the rule
-
dump
Description copied from interface:Dumpable
Dump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.- Specified by:
dump
in interfaceDumpable
- Parameters:
out
- The appendable to dump toindent
- The indent to apply after any new lines.- Throws:
IOException
- if unable to write to Appendable
-