Script traffic with Workshop
Workshop runs your own Lua code on the traffic of the project. Use it to add a header to every request, tag requests for later, or log responses that contain something interesting.

Write a script
Marasi calls processRequest for each request and processResponse for each response. This script adds a header to API requests and logs responses that contain a JWT:
function processRequest(request)
if marasi.strings:has_prefix(request:host(), "api.") then
request:headers():set("X-Test", "1")
end
end
function processResponse(response)
if marasi.strings:contains(response:body(), "eyJ") then
print("JWT in response: " .. response:url():string())
end
endThe editor completes object and method names as you type.
Run the script
- Open the Marasi menu.
- Select Update Workshop.
Marasi runs the code and shows Ran Workshop. If the code has an error, the message shows the error and Marasi keeps your previous code.
To see the output of print(), open the Marasi menu and select Show Logs.
Add a page for your script
A script can draw a small page in the app with marasi.gui. When the script draws an icon and a main view, the page gets its own item in the rail. A button calls a Lua function in your script.
function greet(state)
marasi.gui:update("out", "Hello, " .. (state.name or "you"))
end
marasi.gui:render("icon", { type = "icon", icon = "Box", size = 18 })
marasi.gui:render("main", { type = "v-stack", children = {
{ type = "input", label = "Name", value = { bind = "name" } },
{ type = "button", value = "Greet", on_click = "greet" },
{ type = "text", value = { bind = "out", default = "" } },
}})Things to know
- Lua in Marasi does not include the standard
stringlibrary. Usemarasi.stringsfor text, and the othermarasi.*libraries for encoding and crypto. - Workshop runs after Compass and before Checkpoint. A request that Compass skips never reaches your script.
- To send a new request from a script, use
marasi:builder().