Appearance
Liquid Templating
Liquid is a templating language developed by Shopify for simplying more complex data and structuring requirements. AireGlu uses an implementation of this in order to allow you more control over complex data shaping. A full guide on Liquid can be found on Shopify's documentation. It is recommended that you familiarise yourself with this if you are going to use the Liquid syntax in your endpoints. This page will focus on the AireGlu specifics.
Data shape
You can access data relating to the input and tasks within your endpoint (via input
and tasks
), as well as some data regarding the endpoint run (request
). The data
property is for convenience, and is identical to input
. The exact data shape will vary depending on the construction of your endpoint.
For example, if you had a mapping task (named mapping-task
) and an HTTP Response Handler (named api-resp
) the liquid data shape is:
json
{
"input": {},
"data": {},
"correlationID": "<GuidOrString>",
"transactionId": "<Guid>",
"parameters": {
"mySingleValueParam": "value",
"myMultiValueParam": "valueA,valueB"
},
"parametersArrayed": {
"mySingleValueParam": ["value"],
"myMultiValueParam": ["valueA", "valueB"]
},
"tasks": ["result of mapping-task", "result of api-resp"],
"endpoint": {
"Name": "SimpleEndpointDemo",
"Tasks": [
{
"Format": "XML",
"StatusCode": 200,
"Result": "result of mapping-task",
"Success": true,
"ContentType": "application/xml",
"RedirectUrl": null
},
{
"Format": "JSON",
"StatusCode": 404,
"Result": "result of api-resp",
"Success": false,
"ContentType": "text/json",
"RedirectUrl": null
}
]
},
"request": {
"paths": {
"original": "/my/custom/route",
"redirected": "/endpointName/1"
},
"headers": {
"my-header": "value"
}
}
}
Task results
Note that if you need to access a property on a task result you should use the tasks[0].propertyOne
syntax. If you need the whole result including (for XML or HTML) the outer element and any declarations, then you should use the endpoint.Tasks[0].Result
syntax.
If the result is rendered in a stringified format and you need it as an object then you can use the raw
filter to convert to an object.
Query string parameters
parameters
and parametersArrayed
can be used to access the raw parameters used when calling the endpoint. For example if an endpoint is called with the following parameters ?myParam=1&anotherParam=2
you can access them in either of the following ways:
parameters.myParam
andparameters.anotherParam
orparameters.myParam[0]
andparameters.anotherParam[0]
If the same parameter is included multiple times in the query string then parameters
will combine them into a comma-delimited string, whilst parametersArrayed
will provide them in an array. For example if an endpoint is called with the following parameters ?myParam=1&myParam=2
then parameters.myParam
would return "1,2"
whilst parametersArrayed.myParam
would return ["1","2"]
.
Headers
Any headers the request was called with can be accessed using the property request.headers.myheadername
.
- Some headers, such as x-aireglu-auth and apikey, are blacklisted. These headers cannot be mapped via liquid. For an up to date list of blacklisted headers contact your system admin.
Tasks format
endpoint.Tasks[0].Format
can be any of the following:
JSON
,XML
,QueryString
,HL7v2
,HL7FHIRJSON
,HL7FHIRXML
,HTML
,None
,Text
,Turtle
Route mapping
If you have invoked an endpoint using a custom route you will have access to the following properties:
json
{
"request": {
"paths": {
"original": "/my/custom/route",
"redirected": "/endpointName/1"
}
}
}
See Route Mapping for more information
Looping through items
Some items, such as querystring params or headers, can be looped via liquid. Here is an example that lists all the headers in a request:
"headers": {
{% for header in request.headers %}
"{{header[0] | downcase}}": "{{header[1]}}"{% unless forloop.last %},{% endunless %}
{% endfor %}
}