From b9521eb8f143aaf00773643386cc23e50b1af19b Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Fri, 25 May 2018 02:25:36 +0100 Subject: [PATCH] lib/lua/nb.lua --- lib/lua/nb.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/lua/nb.lua b/lib/lua/nb.lua index 7f4c7cc6..f434e900 100644 --- a/lib/lua/nb.lua +++ b/lib/lua/nb.lua @@ -209,7 +209,6 @@ function nb:api(url,fmt) local res = ngx.location.capture(url) local rows = json.decode(res.body) - if fmt == nil then fmt = '| %s' end local fct -- Function @@ -217,7 +216,7 @@ function nb:api(url,fmt) fct = fmt -- Table - elseif 0 + elseif false or fmt == "table" or fmt == "table-th" or fmt == "table-td" @@ -239,11 +238,18 @@ function nb:api(url,fmt) -- Default else + if fmt == nil then fmt = ', %s' end fct = function(r,i) + local i = 0 for k,v in pairs(r) do - ngx.print(string.format(fmt,v)) - -- ngx.say(v) + i = i + 1 + if i == 1 then + ngx.print(v) + else + ngx.print(string.format(fmt,v)) + end end + ngx.print('\n') end end -- 2.47.3