Simple Header Policy
Description
Set and remove headers on request, response or both. The values can be literal strings, environment, system properties or request headers. Headers can be removed by simple string equality or regular expression.
Plugin
{
"groupId": "io.apiman.plugins",
"artifactId": "apiman-plugins-simple-header-policy",
"version": "3.2.0-SNAPSHOT"
}
Configuration
Option | Type | Description | Default |
---|---|---|---|
addHeaders |
Add and overwrite headers Add headers to a request, response or both. |
None |
|
stripHeaders |
Strip headers Remove headers from a request, response or both when patterns match. |
None |
addHeaders
Option | Type | Description | Default |
---|---|---|---|
headerName |
String |
Header Name The name of the header to set. |
Empty |
headerValue |
String |
Header Value
The value of the header to set, or key into the environment or system properties, depending upon the value of |
Empty |
valueType |
Enum [String, Env, "System Properties", Header] |
Value Type
String:: Treat as a literal value.
Env:: Treat as a key into the environment |
None |
applyTo |
Enum [Request, Response, Both] |
Where to apply rule Request:: Request only. Response:: Response only. Both:: Both request and response. |
None |
overwrite |
Boolean |
Overwrite Overwrite any existing header with same name. |
false |
stripHeaders
Option | Type | Description | Default |
---|---|---|---|
stripType |
Enum[Key, Value] |
Strip when
Key:: |
None |
with |
Enum[String, Regex] |
With matcher type String:: Case-insensitive string equality. Regex:: Case-insensitive regular expression. |
Empty |
pattern |
String |
Using pattern
String to match or compile into a regex, depending on the value of |
Empty |
Sample Configuration
{
"addHeaders": [
{
"headerName": "X-APIMAN-IS",
"headerValue": "free-and-open-source",
"valueType": "String",
"applyTo": "Response",
"overwrite": false
},
{
"headerName": "X-LANG-FROM-ENV",
"headerValue": "LANG",
"valueType": "Env",
"applyTo": "Both",
"overwrite": true
},
{
"headerName": "X-JAVA-VERSION-FROM-PROPS",
"headerValue": "java.version",
"valueType": "System Properties",
"applyTo": "Request",
"overwrite": false
},
{
"headerName": "X-NEW-HTTP-HEADER",
"headerValue": "X-OLD-HTTP-HEADER",
"valueType": "Header",
"applyTo": "Request",
"overwrite": false
}
],
"stripHeaders": [
{
"stripType": "Key",
"with": "String",
"pattern": "Authorization"
},
{
"stripType": "Key",
"with": "Regex",
"pattern": "^password=.*$"
}
]
}