Skip to content

fs_read

fs_read(filename) reads a file from the job’s directory and returns its content as a string. Returns nil if the file does not exist.

fs_read(filename)
async
Param Type Description
filename string File name (relative to job directory)
Value Type Description
content string / nil File content, or nil if file does not exist
function before_fetch(request, ctx)
local cached = fs_read("last_response.json")
if cached then
local data = json_decode(cached)
request.headers["If-None-Match"] = data.etag
end
return request
end