Content-Type Codecs
Codec transformations are supported in Request, Endpoint and Connector units.

Supported Codecs

Xapix currently supports codecs with the corresponding Content-Type regexps (regular expressions).
Content-Type regexp
codec
text/plain
text
application/(.*+)?json
json
application/edn
edn
text/csv
csv
(application|text)/(.*+)?xml
xml
text/html
html
application/x-www-form-urlencoded
x-www-form-urlencoded
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.

Request unit

The following shows a Request example with Content-Type: text/xml.
1
Content-Type: text/xml
2
3
<root level="INFO">
4
<appender-ref ref="CONSOLE"/>
5
</root>
Copied!
The Request unit applies the decode function of the xml codec which results in the following as it appears in the next pipeline unit.
1
{
2
"tag": "root",
3
"attrs": {
4
"level": "debug"
5
},
6
"children": [
7
"\n ",
8
{
9
"tag": "appender-ref",
10
"attrs": {
11
"ref": "STDOUT"
12
}
13
},
14
"\n"
15
]
16
}
Copied!

Endpoint unit

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.

Connector unit

Request

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.

Response

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.
Last modified 10mo ago