add send utilities
This commit is contained in:
parent
c98ceff5ff
commit
4965f76268
@ -553,6 +553,57 @@ 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
|
||||
-- ======================================================================
|
||||
@ -562,3 +613,4 @@ _G.session = session
|
||||
_G.csrf = csrf
|
||||
_G.cookie = cookie
|
||||
_G.password = password
|
||||
_G.send = send
|
||||
|
Loading…
x
Reference in New Issue
Block a user