mirror of
https://github.com/TangentFoxy/lovebird.git
synced 2025-07-28 11:02:19 +00:00
Add json content type
This commit is contained in:
@@ -614,7 +614,12 @@ function lovebird.onrequest(req, client)
|
|||||||
local str
|
local str
|
||||||
xpcall(function()
|
xpcall(function()
|
||||||
local data = lovebird.pages[page](lovebird, req)
|
local data = lovebird.pages[page](lovebird, req)
|
||||||
|
local contenttype = "text/html"
|
||||||
|
if string.match(page, "%.json$") then
|
||||||
|
contenttype = "application/json"
|
||||||
|
end
|
||||||
str = "HTTP/1.1 200 OK\r\n" ..
|
str = "HTTP/1.1 200 OK\r\n" ..
|
||||||
|
"Content-Type: " .. contenttype .. "\r\n" ..
|
||||||
"Content-Length: " .. #data .. "\r\n" ..
|
"Content-Length: " .. #data .. "\r\n" ..
|
||||||
"\r\n" .. data
|
"\r\n" .. data
|
||||||
end, lovebird.onerror)
|
end, lovebird.onerror)
|
||||||
|
Reference in New Issue
Block a user