Defining a Proxy Service Filter
By defining a proxy service filter you can modify the request forwarded by a proxy service in the following ways:
-
Remove specified header fields (in addition to any header fields removed by the filter defined in
ProxyResourceConfig.properties
). -
Add specified header fields.
-
Replace specified strings in the body of the request.
To define a proxy service filter you need to add a configuration file
called
configuration-root/com/escenic/webservice/proxy/ProxyResourceFilterConfig.properties
to one of your configuration layers and add one setting to it:
serviceConfigMapping.
name=
path-
where:
-
name is the name of the proxy service for which you want to a filter.
-
path is the relative path of the configuration file in which the filter is defined.
-
You can add several such entries, one for each proxy service you want to filter. For example:
serviceConfigMapping.myservice1=./MyService1Filter serviceConfigMapping.myservice2=./MyService2Filter
You then need to create the actual filter configuration files you have
referenced. In the case of the above example, you would need to create
two files in the same folder as your
ProxyResourceConfig.properties
file:
configuration-root/com/escenic/webservice/proxy/MyService1Filter.properties
configuration-root/com/escenic/webservice/proxy/MyService2Filter.properties
A filter configuration file can contain the following settings:
filterHeaders=
list-
where list is a comma-separated list of header field names that you want to be removed from the request before it is forwarded. This filter is applied in addition to any filter specified in your
ProxyResourceConfig.properties
file. addHeader.
name=
value-
where:
-
name is the name a header field you want to add to the request before it is forwarded
-
value is the value to be written to the header field
You can specify several such settings in order to add more than one header field to the request.
-
replaceMapping.
pattern=
replacement-
where:
-
pattern is a sequence of characters in the request body that are to be replaced.
-
replacement is the sequence of characters that is to replace pattern.
Only the first occurrence of the specified pattern is replaced.??
-
Here is an example filter configuration file that:
-
Removes two headers called
BadHeader
andWorseHeader
-
Adds a header called
GoodHeader
-
Replaces the string
credentials-here
with the stringverysecretpassword
filterHeaders==BadHeader,WorseHeader addHeader.GoodHeader=very.useful.value replaceMapping.credentials-here=verysecretpassword