2013-07-17 22:55:27 +02:00
|
|
|
local log = require('util.logger')
|
|
|
|
local settings = require('util.settings')
|
|
|
|
|
|
|
|
local M = {
|
|
|
|
isApi = true
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function M._global_GET(request, response)
|
|
|
|
response:setSuccess()
|
|
|
|
for k,v in pairs(request:getAll()) do
|
|
|
|
local r,m = settings.get(k)
|
|
|
|
|
2013-07-29 13:48:56 +02:00
|
|
|
if r ~= nil then response:addData(k, r)
|
2013-07-17 22:55:27 +02:00
|
|
|
else response:addData(k, "could not read key ('" .. m .. "')")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function M._global_POST(request, response)
|
|
|
|
response:setSuccess()
|
|
|
|
|
|
|
|
for k,v in pairs(request:getAll()) do
|
|
|
|
local r,m = settings.set(k, v)
|
|
|
|
|
|
|
|
if r then response:addData(k, "ok")
|
|
|
|
else response:addData(k, "could not set key ('" .. m .. "')")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-07-27 00:25:43 +02:00
|
|
|
function M.all_GET(request, response)
|
|
|
|
for k,v in pairs(settings.getAll()) do
|
|
|
|
response:addData(k,v)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-07-17 22:55:27 +02:00
|
|
|
return M
|