mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
improve headers api
This commit is contained in:
parent
e8d36427ba
commit
4667b801d3
7 changed files with 57 additions and 33 deletions
|
|
@ -233,7 +233,10 @@ local HttpRequest = {__index={
|
|||
return
|
||||
end
|
||||
self.responded = true
|
||||
http_respond(self.server_id, self.id, status or 200, headers or {}, body or "")
|
||||
http_respond(
|
||||
self.server_id, self.id, status or 200,
|
||||
headers or {}, body or ""
|
||||
)
|
||||
end,
|
||||
json=function(self)
|
||||
return json.parse(self.body)
|
||||
|
|
@ -252,7 +255,7 @@ end
|
|||
network.http_json = function(data, status, headers)
|
||||
return {
|
||||
status = status or 200,
|
||||
headers = table.extend({"Content-Type: application/json"}, headers or {}),
|
||||
headers = table.extend({["Content-Type"]="application/json"}, headers or {}),
|
||||
body = json.tostring(data)
|
||||
}
|
||||
end
|
||||
|
|
@ -292,7 +295,7 @@ function Router.__call(self, request)
|
|||
end
|
||||
end
|
||||
end
|
||||
return {status=404, headers={"Content-Type: text/plain"}, body="Not Found"}
|
||||
return {status=404, headers={["Content-Type"]="text/plain"}, body="Not Found"}
|
||||
end
|
||||
|
||||
local function clean(iterable, checkFun, ...)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue