mirror of
https://github.com/akyaiy/GoSally-mvp.git
synced 2026-01-03 15:12:26 +00:00
Refactor configuration and update handling:
- Modify .luarc.json to include global Lua scripts. - Update Makefile to include LDFLAGS for versioning. - Enhance node.go to implement version checking and update handling. - Refactor Lua global variables in _globals.lua and echo.lua to use new structures. - Remove deprecated http.lua and update config.yaml for TLS and update settings. - Introduce new update.go for version management and update checking. - Add tests for version comparison in update_test.go. - Improve error handling in various server methods.
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
---@alias AnyTable table<string, any>
|
||||
|
||||
---@type AnyTable
|
||||
Params = {}
|
||||
In = {
|
||||
Params = {},
|
||||
}
|
||||
|
||||
---@type AnyTable
|
||||
Result = {}
|
||||
Out = {
|
||||
Result = {},
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
---@diagnostic disable: duplicate-set-field
|
||||
package.path = package.path .. ";/usr/lib64/lua/5.1/?.lua;/usr/local/share/lua/5.1/?.lua" .. ";./com/?.lua;"
|
||||
package.cpath = package.cpath .. ";/usr/lib64/lua/5.1/?.so;/usr/local/lib/lua/5.1/?.so"
|
||||
|
||||
@@ -5,4 +6,11 @@ print = function() end
|
||||
io.write = function(...) end
|
||||
io.stdout = function() return nil end
|
||||
io.stderr = function() return nil end
|
||||
io.read = function(...) return nil end
|
||||
io.read = function(...) return nil end
|
||||
|
||||
---@type table<string, any>
|
||||
Status = {
|
||||
ok = "ok",
|
||||
error = "error",
|
||||
invalid = "invalid",
|
||||
}
|
||||
|
||||
10
com/echo.lua
10
com/echo.lua
@@ -2,12 +2,12 @@
|
||||
--- #args
|
||||
--- msg = the message
|
||||
|
||||
if not Params.msg then
|
||||
Result.status = "error"
|
||||
Result.error = "Missing parameter: msg"
|
||||
if not In.Params.msg or In.Params.msg == "" then
|
||||
Out.Result.status = Status.error
|
||||
Out.Result.error = "Missing parameter: msg"
|
||||
return
|
||||
end
|
||||
|
||||
Result.status = "ok"
|
||||
Result.answer = Params.msg
|
||||
Out.Result.status = Status.ok
|
||||
Out.Result.answer = In.Params.msg
|
||||
return
|
||||
15
com/http.lua
15
com/http.lua
@@ -1,15 +0,0 @@
|
||||
package.path = package.path .. ";/usr/lib64/lua/5.1/?.lua;/usr/local/share/lua/5.1/?.lua;" .. ";./com/?.lua;"
|
||||
package.cpath = package.cpath .. ";/usr/lib64/lua/5.1/?.so;/usr/local/lib/lua/5.1/?.so;"
|
||||
|
||||
local https = require("ssl.https")
|
||||
local ltn12 = require("ltn12")
|
||||
|
||||
local response = {}
|
||||
local res, code, headers = https.request{
|
||||
url = "https://localhost:8080/api/v1/echo?msg=sigma",
|
||||
sink = ltn12.sink.table(response)
|
||||
}
|
||||
|
||||
|
||||
Result.msg = table.concat(response)
|
||||
Result.status = "ok"
|
||||
Reference in New Issue
Block a user