response:get(key: string, default: any | nil) --any | nil Get a value from the response object. If the key was never set, the second default parameter is provided instead. This function will throw an error when a raw response body was set using {{response/response:setRawBody}}.
-- First set the response value, then read it back
response:set("foo", { "bar", "hello", "world" })
local foo = response:get("foo")
print(foo[2]) --hello response:set(key: string, value: any) --nil Set a JSON key in the response. All keys in the response will convert to a proper JSON body when the workflow is finished. This function will throw an error when a raw response body was set using {{response/response:setRawBody}}.
response:set("foo", { "bar", "hello", "world" })
-- Response body: {"foo": ["bar", "hello", "world"]} response:setHeader(key: string, value: string) --nil Add the header value by its key to the response. Headers are preserved throughout the entire workflow (unless overwritten).
response:setHeader("cache-control", "public, max-age=3600") response:setRawBody(body: string) --nil Overwrite the response body with raw content. This change will have some impact on the response:
These changes can be mostly undone by calling the function again with an empty string as the body.
response:setStatus(code: number) --nil Add the header value by its key to the response. Headers are preserved throughout the entire workflow (unless overwritten).