Class RewritePatternRule

  • All Implemented Interfaces:
    Rule.ApplyURI

    public class RewritePatternRule
    extends PatternRule
    implements Rule.ApplyURI
    Rewrite the URI by replacing the matched PathMap path with a fixed string.
    • Constructor Detail

      • RewritePatternRule

        public RewritePatternRule()
      • RewritePatternRule

        public RewritePatternRule​(@Name("pattern")
                                  String pattern,
                                  @Name("replacement")
                                  String replacement)
    • Method Detail

      • setReplacement

        public void setReplacement​(String replacement)
        Whenever a match is found, it replaces with this value.
        Parameters:
        replacement - the replacement string.
      • applyURI

        public void applyURI​(org.eclipse.jetty.server.Request request,
                             String oldURI,
                             String newURI)
                      throws 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 parameter param1 = true and _query will contain param1=false the result will be param1=true&param1=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 interface Rule.ApplyURI
        Parameters:
        request - the request
        oldURI - the old URI
        newURI - the new URI
        Throws:
        IOException - if unable to apply the URI