fix http json usage, use native implementation
This commit is contained in:
parent
1e19ba7700
commit
6f20540720
@ -1,6 +1,7 @@
|
|||||||
-- modules/http.lua - Express-like HTTP server with pure Lua routing
|
-- modules/http.lua - Express-like HTTP server with pure Lua routing
|
||||||
|
|
||||||
local http = {}
|
local http = {}
|
||||||
|
local json = require("json")
|
||||||
|
|
||||||
-- Global routing tables (shared across all states)
|
-- Global routing tables (shared across all states)
|
||||||
_G._http_routes = _G._http_routes or {}
|
_G._http_routes = _G._http_routes or {}
|
||||||
@ -308,7 +309,7 @@ function Request:json()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local success, result = pcall(function()
|
local success, result = pcall(function()
|
||||||
return moonshark.json_decode(self.body)
|
return json.decode(self.body)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if success then
|
if success then
|
||||||
@ -391,7 +392,7 @@ function Response:json(data)
|
|||||||
self:type("application/json")
|
self:type("application/json")
|
||||||
|
|
||||||
local success, json_str = pcall(function()
|
local success, json_str = pcall(function()
|
||||||
return moonshark.json_encode(data)
|
return json.encode(data)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if success then
|
if success then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user