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
public class RewritePatternRule extends PatternRule implements Rule.ApplyURI
Rewrite the URI by replacing the matchedPathMap
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
Constructors Constructor Description RewritePatternRule()
RewritePatternRule(java.lang.String pattern, java.lang.String replacement)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
apply(java.lang.String target, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Apply the rule to the requestvoid
applyURI(Request request, java.lang.String oldURI, java.lang.String newURI)
This method will add _query to the requests's queryString and also combine it with existing queryStrings in the request.void
setReplacement(java.lang.String replacement)
Whenever a match is found, it replaces with this value.java.lang.String
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
-
-
-
-
Method Detail
-
setReplacement
public void setReplacement(java.lang.String replacement)
Whenever a match is found, it replaces with this value.- Parameters:
replacement
- the replacement string.
-
apply
public java.lang.String apply(java.lang.String target, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.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:
java.io.IOException
- exceptions dealing with operating on request or response objects
-
applyURI
public void applyURI(Request request, java.lang.String oldURI, java.lang.String newURI) throws java.io.IOException
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:
java.io.IOException
- if unable to apply the URI
-
toString
public java.lang.String toString()
Returns the replacement string.- Overrides:
toString
in classPatternRule
-
-