mirror of
https://github.com/lxsang/antd-web-apps
synced 2024-11-20 02:18:20 +01:00
minor fix on apigateway handling
This commit is contained in:
parent
4016a0abef
commit
5b8acf2d87
@ -140,10 +140,12 @@ function SystemController:apigateway(...)
|
|||||||
r, e = load(data.code)
|
r, e = load(data.code)
|
||||||
if r then
|
if r then
|
||||||
local status, result = pcall(r)
|
local status, result = pcall(r)
|
||||||
if (status) then
|
if result then
|
||||||
echo(JSON.encode(result))
|
if (status) then
|
||||||
else
|
echo(JSON.encode(result))
|
||||||
echo(result)
|
else
|
||||||
|
echo(result)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
echo(e)
|
echo(e)
|
||||||
@ -169,12 +171,13 @@ function SystemController:apigateway(...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if (is_auth()) then
|
if (is_auth()) then
|
||||||
local pid = ulib.fork()
|
local pid = ulib.fork()--std.pfork(HTTP_REQUEST.id)
|
||||||
if (pid == -1) then
|
if (pid == -1) then
|
||||||
echo("{'error':'Cannot create process'}")
|
echo("{'error':'Cannot create process'}")
|
||||||
elseif pid > 0 then -- parent
|
elseif pid > 0 then -- parent
|
||||||
-- wait for the child exit or websocket exit
|
-- wait for the child exit or websocket exit
|
||||||
ulib.waitpid(pid, 0)
|
ulib.waitpid(pid, 0)
|
||||||
|
--ulib.kill(pid)
|
||||||
print("Parent exit")
|
print("Parent exit")
|
||||||
else -- child
|
else -- child
|
||||||
if use_ws then
|
if use_ws then
|
||||||
@ -189,7 +192,7 @@ function SystemController:apigateway(...)
|
|||||||
std.ws.close(1012)
|
std.ws.close(1012)
|
||||||
elseif header.opcode == std.ws.CLOSE then
|
elseif header.opcode == std.ws.CLOSE then
|
||||||
print("Connection closed")
|
print("Connection closed")
|
||||||
std.ws.close(1000)
|
-- std.ws.close(1000)
|
||||||
elseif header.opcode == std.ws.TEXT then
|
elseif header.opcode == std.ws.TEXT then
|
||||||
-- read the file
|
-- read the file
|
||||||
local data = std.ws.read(header)
|
local data = std.ws.read(header)
|
||||||
@ -198,7 +201,7 @@ function SystemController:apigateway(...)
|
|||||||
exec_with_user_priv(data)
|
exec_with_user_priv(data)
|
||||||
std.ws.close(1011)
|
std.ws.close(1011)
|
||||||
else
|
else
|
||||||
echo("Error: Invalid request")
|
print("Error: Invalid request")
|
||||||
std.ws.close(1011)
|
std.ws.close(1011)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user