Codec transformations are supported in Request, Endpoint and Connector units.
Xapix currently supports codecs with the corresponding Content-Type regexps (regular expressions).
Content-Type regexp | codec |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
If one of the regexps matches the Content-Type
then the corresponding codec will be applied.
Each unit calls either the encode
or decode
function of a codec, depending on if it is an input or output of unit. See the following sections for details.
The following shows a Request example with Content-Type: text/xml
.
Content-Type: text/xml​<root level="INFO"><appender-ref ref="CONSOLE"/></root>
The Request unit applies the decode
function of the xml
codec which results in the following as it appears in the next pipeline unit.
{"tag": "root","attrs": {"level": "debug"},"children": ["\n ",{"tag": "appender-ref","attrs": {"ref": "STDOUT"}},"\n"]}
Endpoint unit applies the decode
function of codec to body
. The codec is determined by the Content-Type
header.
For example, if the endpoint parameters has a Content-Type: text/xml
header, then the xml
decoder will be applied to the body
parameter.
A connector unit applies the encode
function of a codec to body
.
The codec is determined by Content-Type
header. For example, if a connector parameter has Content-Type: text/xml
header then the xml
encoder will be applied to body
parameter.
A connector unit applies the decode
function of the codec to body
. Codec is determined by Content-Type
header. For example, if the Connector parameter has Content-Type: text/xml
header then xml
decoder will be applied to body
parameter.