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 matchedPathMappath 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(String pattern, String replacement)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringapply(String target, HttpServletRequest request, HttpServletResponse response)Apply the rule to the requestvoidapplyURI(org.eclipse.jetty.server.Request request, String oldURI, String newURI)This 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.StringtoString()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(String replacement)
Whenever a match is found, it replaces with this value.- Parameters:
replacement- the replacement string.
-
apply
public String apply(String target, HttpServletRequest request, 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
public void applyURI(org.eclipse.jetty.server.Request request, String oldURI, String newURI) throws IOExceptionThis 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
public String toString()
Returns the replacement string.- Overrides:
toStringin classPatternRule
-
-