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.luaJSON 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")
local kv   = require("kv")

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 }
)

kv.lua API

The kv module connects to the RapidForge KV store configured via RF_KV_URL. It is available in every Lua script automatically — no extra setup needed.

  • kv.get(key) -> value | nil
    • Returns the stored string value, or nil if the key does not exist.
  • kv.set(key, value) -> true | nil, err
    • Stores a string value. Returns true on success, or nil + error message on failure.
  • kv.del(key) -> true | nil
    • Deletes the key. Returns true if deleted, nil if the key was not found.
  • kv.list() -> table
    • Returns an array of all stored keys.

Example:

local kv = require("kv")

local ok, err = kv.set("last-run", os.date("%Y-%m-%d"))
if not ok then error(err) end

local value = kv.get("last-run")
print("last run:", value)

local keys = kv.list()
for _, k in ipairs(keys) do
  print(k)
end

kv.del("last-run")