local xml = require("LuaXml") require("os") local cjson = require "cjson" local path = ngx.var.request:split(" ")[2] local m = ngx.re.match(path,[=[/([^/]+)\.(json|xml)$]=]) -- match last word local res = ngx.location.capture("/v1/word/".. m[1] .. ".json" ) local value=cjson.new().decode(res.body) local response = xml.new("response") response.word= xml.new("word") response.sentiment = xml.new("sentiment") response.timestamp = xml.new("timestamp") table.insert(response.word, value.word) table.insert(response.sentiment, value.sentiment) table.insert(response.timestamp, os.date()) ngx.say('', xml.str(response,0))