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
_pattern
Fields inherited from class org.eclipse.jetty.rewrite.handler.Rule
_handling, _terminating
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionapply
(String target, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Apply the rule to the requestvoid
This method will add _query to the requests's queryString and also combine it with existing queryStrings in the request.void
setReplacement
(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, setPattern
Methods 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, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws IOException Description copied from class:PatternRule
Apply the rule to the request- Specified by:
apply
in 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 = true
and _query will containparam1=false
the 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:
applyURI
in 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:
toString
in classPatternRule
-