Cloud LUA server-side handling for the sandbox.
8.2K
The default behavior of cloud-lua-sandbox is to read JSON-RPC data from stdin
(newline-separated JSON-RPC messages), write results to stdout, and then exit.
By passing -L PORT command line argument, the program will listen on TCP port
PORT and process JSON-RPC messages on each connection opened.
Additionally, if the -h option is passed, the program will enable basic HTTP
handling by unwrapping JSON-RPC requests from HTTP requests, and wrapping
JSON-RPC responses into HTTP responses. The Access-Control-Allow-Origin: *
CORS header is passed on every request so it can more easily be used by the Lua
sandbox frontend. Only POST requests on /jsonrpc are accepted.
For example, cloud-lua-sandbox -L 5555 -h will create a JSON-RPC endpoint at
http://127.0.0.1:5555/jsonrpc
Which can then be called by something similar to this:
fetch('http://localhost:5555/jsonrpc', {
method: "POST",
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "run",
params: {
events: [{log: "one"}],
filter: `function cb_filter(tag, ts, record)
return 1, ts, record
end`
}
})
}).then(async (resp) => {
console.log('RESPONSE', await resp.json());
})
Content type
Image
Digest
sha256:8cb4d5009…
Size
34.3 MB
Last updated
6 months ago
docker pull calyptia/cloud-lua-sandbox