Class ResponseStatusHeaderRegexRule

java.lang.Object
org.eclipse.jetty.rewrite.handler.Rule
org.eclipse.jetty.rewrite.handler.ResponseStatusHeaderRegexRule

public class ResponseStatusHeaderRegexRule extends Rule
Sends a response with the configured status code whenever the value of the configured request header matches a regular expression.
  • Constructor Details

    • ResponseStatusHeaderRegexRule

      public ResponseStatusHeaderRegexRule()
  • Method Details

    • isTerminating

      public boolean isTerminating()
      Overrides:
      isTerminating in class Rule
      Returns:
      whether rules after this one are not invoked
    • getHeaderName

      public String getHeaderName()
    • setHeaderName

      public void setHeaderName(String headerName)
      Set the http header to match on
      Parameters:
      headerName - the http header to match on
    • getHeaderRegex

      public String getHeaderRegex()
    • setHeaderRegex

      public void setHeaderRegex(String headerRegex)
      Set the regex to match against the header value, null to match on any value
      Parameters:
      headerRegex - regex to match against the header value
    • getCode

      public int getCode()
    • setCode

      public void setCode(int code)
      Set the http status code returned on a match.
      Parameters:
      code - the http status code
    • getMessage

      public String getMessage()
    • setMessage

      public void setMessage(String message)

      Sets the message for the response body.

      Parameters:
      message - the response body message
    • matchAndApply

      public Rule.Handler matchAndApply(Rule.Handler input) throws IOException
      Description copied from class: Rule

      Tests whether the given input Handler (which wraps a Request) matches the rule, and if so returns an output Handler that applies the rule logic.

      If the input does not match, null is returned.

      Specified by:
      matchAndApply in class Rule
      Parameters:
      input - the input Handler that wraps the Request
      Returns:
      an output Handler that wraps the input Handler, or null if the rule does not match
      Throws:
      IOException - if applying the rule fails
    • apply

      public Rule.Handler apply(Rule.Handler input, String value) throws IOException
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Rule