-
Notifications
You must be signed in to change notification settings - Fork 1
ConfigXml
- Introduction
- response-header-mapper
- processorClass
- mapping
- url
- processorClass
- default
- conditional
- queryParamName
- queryParamValue
- response-headers
The file response-header-filter.xml contains instructions for the filter to process requests. It basically contains a set of mappings which are internally processed as Rules. If an incoming request is found to be a match with one of the mappings, the corresponding Rules are applied to the response.
For a sample mapping file, click here The file content is processed according to these rules:
-
The file should have response-header-mapper as the root node.
-
Each node (in the xml) with the name mapping is identified as mapping rule and
gets converted into a Rule.
url is a mandatory attribute in the mapping node; mappings without a url are rejected. -
Subsequent mappings for the same url will OVERRIDE the previous Rule.
Last Rule wins. -
Each mapping can have only one
defaultresponse-header list.
In cases of multiple such declarations, the Last<default>declaration wins. -
Each mapping can have any number of
conditionalmappings.
All these rules are treated as mutually exclusive. -
Both, default and conditional nodes should have a
<response-headers>node. In case of multiple such nodes, Last<response-headers>declaration wins. -
Each
<response-headers>node may contain one or more<header>nodes. Each such node has to have two mandatory attributes,keyandvalue. -
Both,
queryParamNameandqueryParamValue, are required attributes in a conditional tag. They can't be left blank or undeclared. -
Values inside the
queryParamValueattribute are parsed as aPattern.
-
Description: This is the root node for the filter configuration file and is a expected node.
-
Required: Yes
-
Attributes:
- Description: A fully qualified class name for the processor class, if you want to process the response headers on your own. You would need a processor class when setting the headers needs to be done after some sort of evaluation over the request and/or response.
Your class should implement thecom.avlesh.web.filter.responseheaderfilter.MappingProcessorinterface. - Required: No
- Default:
com.avlesh.web.filter.responseheaderfilter.DefaultMappingProcessor
- Description: A fully qualified class name for the processor class, if you want to process the response headers on your own. You would need a processor class when setting the headers needs to be done after some sort of evaluation over the request and/or response.
-
Description: A
mappingnode is set of rules for a matchingurlpattern. -
Required: Yes
-
Attributes:
- Description: The base url to which the corresponding mapping should be applied to. This is only supposed to be the
uri. To be able to use your requestqueryString, read the conditional node section. - Required: Yes
- Example:
<mapping url="/ajax/*.html">
- Description: The base url to which the corresponding mapping should be applied to. This is only supposed to be the
-
Description: A fully qualified class name for the processor class for this particular mapping, if you want to process the response headers on your own or differently from other mappings. You would need a processor class when setting the headers needs to be done after some sort of evaluation over the request and/or response.
Your class should implement thecom.avlesh.web.filter.responseheaderfilter.MappingProcessorinterface. -
Required: No
-
Default:
com.avlesh.web.filter.responseheaderfilter.DefaultMappingProcessor -
Example:
<mapping url="/ajax/*.html" processorClass="com.foo.MyAjaxProcessor">
-
Description: One of the possible child nodes for a
mappingnode. Rules specified under default is the default fallback in case of absence ofconditionalnodes. Each mapping can have only one default. If you specify multiple such default's the last one is respected. -
Required: No
-
Example:
<mapping url="/ajax/*.html"> <default> <response-headers> <header key="Content-Type" value="text/xml"/> <header key="Cache-Control" value="no-cache"/> </response-headers> </default> </mapping> -
Description: One of the possible child nodes for a
mappingnode. Amappingnode may have many conditional nodes. The conditional nodes can be used to apply specific and different set of rules based on query parameters for the request. -
Required: No
-
Attributes:
- Description: The query parameter based on which you want to have a
conditionalrule. e.g. you may want to apply different response headers to/site/log-analyzer.html?type=xxxxbased on thetypeparameter. YourqueryParamNamein this case would be type. - Required: Yes
- Description: The query parameter based on which you want to have a
-
Description: In the above example, the value has to be specified in the
queryParamValueattribute. This also takes aPattern. -
Required: Yes
-
Example:
<mapping url="/ajax/*.html"> <conditional queryParamName="type" queryParamValue="(country|city)"> <response-headers> <header key="Content-Type" value="text/xml"/> <header key="Cache-Control" value="private, max-age=86400"/> </response-headers> </conditional> </mapping>- NOTE: Conditional rules are evaluated from bottom to top. Last matching rule (in the config) wins.
Any default or conditional node is considered invalid without a list response-headers that needs to be applied for a particular mapping. A response-headers node comprises of a list of header nodes.
This the lowest unit in the configuration. Each header is a specific response header that needs to be applied to the
response. A header comprises of key: To be specific, a response-header key.
value: The value for the above mentioned key.