gluon-announced: Respond to single-word requests with uncompressed info

This commit is contained in:
Jan-Philipp Litza 2015-08-31 22:38:33 +02:00
parent a71ab2fb72
commit 193e2ac6b4

View File

@ -11,10 +11,6 @@ end
module('gluon.announced', package.seeall) module('gluon.announced', package.seeall)
function handle_request(query) function handle_request(query)
if query:match('^nodeinfo$') then
return json.stringify(collect('nodeinfo'))
end
local m = query:match('^GET ([a-z ]+)$') local m = query:match('^GET ([a-z ]+)$')
if m then if m then
local data = {} local data = {}
@ -29,5 +25,10 @@ function handle_request(query)
if next(data) then if next(data) then
return deflate.compress(json.stringify(data)) return deflate.compress(json.stringify(data))
end end
elseif query:match('^[a-z]+$') then
local ok, data = pcall(collect, query)
if ok then
return json.stringify(data)
end
end end
end end