Access data via HTTP
Besides an MQTT Broker the Crosser Node comes with an integrated HTTP Server which can be used to ingest or extract data. Combining the HTTP Listener and HTTP Response modules allows you to create flows that generate custom responses to HTTP requests such as GET/POST/UPDATE etc.
For this example let’s assume we have stored the state of a specific machine in the Key Value Store on the Node. We can set up a flow that:
- Opens up an HTTP endpoint ‘machine_status’ which allows GET operations with query parameters.
- In this case we use ‘machine_name’ as a query parameter which is then used as the lookup-key in the Key Value Get Module.
- If the module finds the key, it returns the result as JSON to the requested client.
- If the module does not find the key it returns a custom response.
Message filters on the modules are used to verify the result of the Key Value Get module.
Crosser Example Flow
Request for existing machine:
curl --location --request GET http://:9090/machine_status?machine_name=machine_1
Response:
[ { "rValue": 20.061224928982055, "sName": "temp", "sUnit": "Double" }, { "rValue": 1130.857727624256, "sName": "pressure", "sUnit": "Double" } ]
Note: By default the HTTP Server is not configured for secure connections. Read more about how to set up secure endpoints in this article.