Skip to main content

Module lua_runtime

Module lua_runtime 

Source
Expand description

Lua scripting runtime for the script plugin, built on mlua’s Luau VM.

Marshals the gateway Context into a Lua table, calls the script’s global execute(ctx) function, and marshals the returned table back into a Context. Also installs a sandboxed require restricted to a configured modules directory.

Structs§

LuaRuntime
Holds a validated Lua script and executes it against a Context.

Functions§

context_to_lua 🔒
Marshals a Context into a Lua table with request, response, and message sub-tables. Header and query-param values become 1-indexed arrays of strings; bodies become Lua strings; message values are converted from JSON. errors is not exposed to scripts.
json_to_lua 🔒
Converts a JSON value to the corresponding Lua value (arrays become 1-indexed tables, objects become string-keyed tables).
lua_to_context 🔒
Rebuilds a Context from the table returned by the script’s execute.
lua_to_json 🔒
Converts a Lua value back to JSON. Tables with a non-zero sequence length become JSON arrays, other tables become objects with string keys; unconvertible values (functions, userdata, non-UTF-8 strings) degrade to null or empty strings rather than erroring.
setup_module_loader 🔒
Registers a custom require() loader that reads .lua files from the modules directory.