From 4965f76268d2c4a3b91b4e0524e22875111e1d80 Mon Sep 17 00:00:00 2001 From: Sky Johnson Date: Tue, 20 May 2025 22:49:23 -0500 Subject: [PATCH] add send utilities --- runner/lua/sandbox.lua | 60 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 4 deletions(-) diff --git a/runner/lua/sandbox.lua b/runner/lua/sandbox.lua index 3319e1e..a526ae3 100644 --- a/runner/lua/sandbox.lua +++ b/runner/lua/sandbox.lua @@ -553,12 +553,64 @@ function password.verify(plain_password, hash_string) return __password_verify(plain_password, hash_string) end +-- ====================================================================== +-- SEND MODULE +-- ====================================================================== + +local send = {} + +function send.html(content) + http.set_content_type("text/html") + return content +end + +function send.json(content) + http.set_content_type("application/json") + return content +end + +function send.text(content) + http.set_content_type("text/plain") + return content +end + +function send.xml(content) + http.set_content_type("application/xml") + return content +end + +function send.javascript(content) + http.set_content_type("application/javascript") + return content +end + +function send.css(content) + http.set_content_type("text/css") + return content +end + +function send.svg(content) + http.set_content_type("image/svg+xml") + return content +end + +function send.csv(content) + http.set_content_type("text/csv") + return content +end + +function send.binary(content, mime_type) + http.set_content_type(mime_type or "application/octet-stream") + return content +end + -- ====================================================================== -- REGISTER MODULES GLOBALLY -- ====================================================================== -_G.http = http -_G.session = session -_G.csrf = csrf -_G.cookie = cookie +_G.http = http +_G.session = session +_G.csrf = csrf +_G.cookie = cookie _G.password = password +_G.send = send