add send utilities

This commit is contained in:
Sky Johnson 2025-05-20 22:49:23 -05:00
parent c98ceff5ff
commit 4965f76268

View File

@ -553,6 +553,57 @@ function password.verify(plain_password, hash_string)
return __password_verify(plain_password, hash_string) return __password_verify(plain_password, hash_string)
end 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 -- REGISTER MODULES GLOBALLY
-- ====================================================================== -- ======================================================================
@ -562,3 +613,4 @@ _G.session = session
_G.csrf = csrf _G.csrf = csrf
_G.cookie = cookie _G.cookie = cookie
_G.password = password _G.password = password
_G.send = send