Class RewritePatternRule
java.lang.Object
org.eclipse.jetty.rewrite.handler.Rule
org.eclipse.jetty.rewrite.handler.PatternRule
org.eclipse.jetty.rewrite.handler.RewritePatternRule
- All Implemented Interfaces:
Rule.ApplyURI
Rewrite the URI by replacing the matched
ServletPathSpec path with a fixed string.-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jetty.rewrite.handler.Rule
Rule.ApplyURI -
Field Summary
Fields inherited from class org.eclipse.jetty.rewrite.handler.PatternRule
_patternFields inherited from class org.eclipse.jetty.rewrite.handler.Rule
_handling, _terminating -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapply(String target, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Apply the rule to the requestvoidThis method will add _query to the requests's queryString and also combine it with existing queryStrings in the request.voidsetReplacement(String replacement) Whenever a match is found, it replaces with this value.toString()Returns the replacement string.Methods inherited from class org.eclipse.jetty.rewrite.handler.PatternRule
getPattern, matchAndApply, setPatternMethods inherited from class org.eclipse.jetty.rewrite.handler.Rule
isHandling, isTerminating, setHandling, setTerminating
-
Constructor Details
-
RewritePatternRule
public RewritePatternRule() -
RewritePatternRule
-
-
Method Details
-
setReplacement
Whenever a match is found, it replaces with this value.- Parameters:
replacement- the replacement string.
-
apply
public String apply(String target, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException Description copied from class:PatternRuleApply the rule to the request- Specified by:
applyin classPatternRule- Parameters:
target- field to attempt matchrequest- request objectresponse- response object- Returns:
- The target (possible updated)
- Throws:
IOException- exceptions dealing with operating on request or response objects
-
applyURI
This method will add _query to the requests's queryString and also combine it with existing queryStrings in the request. However it won't take care for duplicate. E.g. if request.getQueryString contains a parameterparam1 = trueand _query will containparam1=falsethe result will beparam1=true¶m1=false. To cover this use case some more complex pattern matching is necessary. We can implement this if there's use cases.- Specified by:
applyURIin interfaceRule.ApplyURI- Parameters:
request- the requestoldURI- the old URInewURI- the new URI- Throws:
IOException- if unable to apply the URI
-
toString
Returns the replacement string.- Overrides:
toStringin classPatternRule
-