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.ApplyURINested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected Stringprotected booleanprotected booleanprotected Rule[]static final StringFields inherited from class org.eclipse.jetty.rewrite.handler.Rule
_handling, _terminating -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a Ruleprotected Stringapply(String target, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Process the contained rules (called by matchAndApply)voiddump(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.booleanbooleanmatchAndApply(String target, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Process the contained rulesvoidsetOriginalPathAttribute(String originalPathAttribte) voidsetRewritePathInfo(boolean rewritePathInfo) voidsetRewriteRequestURI(boolean rewriteRequestURI) voidAssigns 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:
matchAndApplyin 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:DumpableDump 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:
dumpin interfaceDumpable- Parameters:
out- The appendable to dump toindent- The indent to apply after any new lines.- Throws:
IOException- if unable to write to Appendable
-