Class ResponseStatusHeaderRegexRule
java.lang.Object
org.eclipse.jetty.rewrite.handler.Rule
org.eclipse.jetty.rewrite.handler.ResponseStatusHeaderRegexRule
Sends a response with the configured status code whenever the value of the configured request header matches a regular expression.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jetty.rewrite.handler.Rule
Rule.Handler, Rule.HttpURIHandler
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionapply
(Rule.Handler input, String value) int
getCode()
boolean
matchAndApply
(Rule.Handler input) Tests whether the given inputHandler
(which wraps aRequest
) matches the rule, and if so returns an outputHandler
that applies the rule logic.void
setCode
(int code) Set the http status code returned on a match.void
setHeaderName
(String headerName) Set the http header to match onvoid
setHeaderRegex
(String headerRegex) Set the regex to match against the header value, null to match on any valuevoid
setMessage
(String message) Sets the message for the response body.toString()
Methods inherited from class org.eclipse.jetty.rewrite.handler.Rule
setTerminating
-
Constructor Details
-
ResponseStatusHeaderRegexRule
public ResponseStatusHeaderRegexRule()
-
-
Method Details
-
isTerminating
public boolean isTerminating()- Overrides:
isTerminating
in classRule
- Returns:
- whether rules after this one are not invoked
-
getHeaderName
-
setHeaderName
Set the http header to match on- Parameters:
headerName
- the http header to match on
-
getHeaderRegex
-
setHeaderRegex
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
-
setMessage
Sets the message for the response body.
- Parameters:
message
- the response body message
-
matchAndApply
Description copied from class:Rule
Tests whether the given input
Handler
(which wraps aRequest
) matches the rule, and if so returns an outputHandler
that applies the rule logic.If the input does not match,
null
is returned.- Specified by:
matchAndApply
in classRule
- Parameters:
input
- the inputHandler
that wraps theRequest
- Returns:
- an output
Handler
that wraps the inputHandler
, ornull
if the rule does not match - Throws:
IOException
- if applying the rule fails
-
apply
- Throws:
IOException
-
toString
-