Content-Type codecs

Codec transformations are supported in request, endpoint and data source 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.

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

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.

Data source unit

Request

A data source unit applies the encode function of a codec to body.

The codec is determined by Content-Type header. For example, if a data source parameter has Content-Type: text/xml header then the xml encoder will be applied to body parameter.

Response

Data source unit applies the decode function of the codec to body. Codec is determined by Content-Type header. For example, if data source parameters has Content-Type: text/xml header then xml decoder will be applied to body parameter.