RapidForge supports mruby as a built-in script runtime for webhooks, periodic tasks, and on-fail scripts. Choose mruby when you want Ruby syntax without installing Ruby on the host machine.

The bundled runtime includes JSON support and HTTP helpers backed by mruby-curl. RapidForge starts every mRuby script with a small compatibility layer because this runtime does not expose Ruby's usual ENV or require.

Accessing Environment Variables

Use the env helper to read values injected by RapidForge:

payload = env("PAYLOAD_DATA")
token = env("CRED_API_TOKEN")

All injected values are also available in the RAPIDFORGE_ENV hash:

RAPIDFORGE_ENV.each do |key, value|
  puts "#{key}=#{value}"
end

JSON

Use JSON.parse and JSON.generate for JSON work:

data = JSON.parse(env("PAYLOAD_DATA") || "{}")
puts JSON.generate({ ok: true, received: data })

HTTP Helpers

All HTTP helpers return two values: response body and HTTP status code.

body, status = http_get(
  "https://httpbin.org/get",
  { "User-Agent" => "rapidforge/mruby" }
)

payload = JSON.generate({ hello: "world" })
body, status = http_post(
  "https://httpbin.org/post",
  payload,
  { "Content-Type" => "application/json" }
)

if status == 200 || status == 201
  puts JSON.parse(body)["json"]["hello"]
else
  STDERR.puts "request failed: #{status}"
end

Available helpers:

  • http_get(url, headers = {})
  • http_post(url, body = "", headers = {})
  • http_put(url, body = "", headers = {})
  • http_patch(url, body = "", headers = {})
  • http_delete(url, headers = {})

KV Helpers

mRuby scripts can use the RapidForge KV store directly:

kv_set("last-run", "2026-07-09T12:00:00Z")

value = kv_get("last-run")
puts "last run: #{value}"

keys = kv_list()
puts keys.join(",")

deleted = kv_del("last-run")
puts "deleted: #{deleted}"

Available helpers:

  • kv_get(key) returns the stored string value, or nil if the key does not exist.
  • kv_set(key, value) returns true on success.
  • kv_del(key) returns true if a key was deleted, or false if it was missing.
  • kv_list() returns an array of stored keys.

Notes

RapidForge uses Ruby syntax highlighting for mruby in the editor. Autocomplete includes RapidForge helpers plus common mRuby snippets for classes, modules, hashes, arrays, JSON, HTTP, and KV usage.