Add json content type

This commit is contained in:
Cameron McHenry 2017-04-28 21:29:55 -04:00
parent d34197debb
commit 160114b7ed
2 changed files with 10 additions and 0 deletions

View File

@ -614,7 +614,12 @@ function lovebird.onrequest(req, client)
local str
xpcall(function()
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" ..
"Content-Type: " .. contenttype .. "\r\n" ..
"Content-Length: " .. #data .. "\r\n" ..
"\r\n" .. data
end, lovebird.onerror)

5
main.lua Normal file
View File

@ -0,0 +1,5 @@
lovebird = require "lovebird"
function love.update()
lovebird.update()
end