If bash script is not enough you can use other languages with RapidForge. However, those require you to install dependencies on host machine. If you don't want to do that RapidForge comes with its own embedded Lua Vm. Note that RapidForge will priorities Lua Vm if that is installed on host machine. That will be useful in case native dependencies you would like to use with Lua. Embeded Lua Vm has libraries that you can use as well.
RapidForge Lua Libraries
json.lua
— JSON encoder/decoder (MIT, by rxi)http.lua
— Minimal HTTP client built on top of curl
Loading the modules
local json = require("json")
local http = require("http")
json.lua API
json.encode(value) -> string
- Encodes Lua values into JSON.
- Tables with sequential numeric keys are arrays; string-keyed tables are objects.
- Errors on sparse arrays, mixed keys, or non-finite numbers.
json.decode(str) -> any
- Decodes a JSON string into Lua values.
- Errors on invalid JSON or trailing data.
Example:
local payload = { hello = "world", nums = {1,2,3} }
local s = json.encode(payload)
local t = json.decode(s)
http.lua API
All functions return two values: response body (string or nil) and HTTP status code (number, or 0 on failure).
http.get(url, headers?) -> body, status
http.delete(url, headers?) -> body, status
http.post(url, data?, headers?) -> body, status
http.put(url, data?, headers?) -> body, status
Headers are provided as a Lua table of ["Header-Name"] = "value"
.
Examples:
local body, status = http.get(
"https://httpbin.org/get",
{ ["User-Agent"] = "rapidforge/luarunner", Accept = "application/json" }
)
local payload = json.encode({ hello = "world" })
local body, status = http.post(
"https://httpbin.org/post",
payload,
{ ["Content-Type"] = "application/json" }
)
if status == 200 or status == 201 then
local obj = json.decode(body)
print(obj.json.hello)
else
io.stderr:write("request failed: ", status, "\n")
end
local token = os.getenv("TOKEN")
local _, status = http.delete(
"https://httpbin.org/delete",
{ Authorization = "Bearer " .. token }
)