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
The most important factor to know when starting is the shape of the data you're working with. This varies, but as a rule, it'll follow the shape you've defined for the input and other tasks. These are accessed via the input
and tasks
properties from liquid. The data
property is for convenience, and is identical to input
.
In effect, if you had a mapping task (named mapping-task
) and an HTTP Response Handler (named api-resp
) you could say the liquid data shape is:
json
{
"input": {},
"data": {},
"parameters": {
"getParamSingle": "value",
"getParamMulti": "valueA,valueB"
},
"parametersArrayed": {
"getParamSingle": ["value"],
"getParamMulti": ["valueA", "valueB"]
},
"tasks": ["result of mapping-task", "result of api-resp"],
"endpoint": {
"Name": "SimpleEndpointDemo",
"EnvironmentOrVersion": "Production",
"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
}
]
}
}
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 a request was called via 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.
Environment or version
endpoint.EnvironmentOrVersion
can be Staging
, Production
, or the version number of the endpoint (e.g. 1
), based on the URL used to call the endpoint.
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 also 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 %}
}