Class HeaderRegexRule


public class HeaderRegexRule extends RegexRule
Rule to add a header based on a Regex match
  • Constructor Details

    • HeaderRegexRule

      public HeaderRegexRule()
    • HeaderRegexRule

      public HeaderRegexRule(@Name("regex") String regex, @Name("name") String name, @Name("value") String value)
  • Method Details

    • setName

      public void setName(String name)
      Sets the header name.
      Parameters:
      name - name of the header field
    • setValue

      public void setValue(String value)
      Sets the header value. The value can be either a String or int value.
      Parameters:
      value - of the header field
    • setAdd

      public void setAdd(boolean add)
      Sets the Add flag.
      Parameters:
      add - If true, the header is added to the response, otherwise the header it is set on the response.
    • apply

      protected String apply(String target, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Matcher matcher) throws IOException
      Description copied from class: RegexRule
      Apply this rule to the request/response pair. Called by RegexRule.matchAndApply(String, HttpServletRequest, HttpServletResponse) if the regex matches.
      Specified by:
      apply in class RegexRule
      Parameters:
      target - field to attempt match
      request - request object
      response - response object
      matcher - The Regex matcher that matched the request (with capture groups available for replacement).
      Returns:
      The target (possible updated).
      Throws:
      IOException - exceptions dealing with operating on request or response objects
    • getName

      public String getName()
      Returns the header name.
      Returns:
      the header name.
    • getValue

      public String getValue()
      Returns the header value.
      Returns:
      the header value.
    • isAdd

      public boolean isAdd()
      Returns:
      the add flag value.
    • toString

      public String toString()
      Description copied from class: RegexRule
      Returns the regular expression string.
      Overrides:
      toString in class RegexRule
      Returns:
      the header contents.