Initial support for Lua script engine

This commit is contained in:
Felipe Zimmerle
2017-11-05 10:42:40 -03:00
parent 1866a3a9eb
commit a676f313c3
19 changed files with 1270 additions and 59 deletions

View File

@@ -0,0 +1,20 @@
function main()
ret = nil
var = m.getvar("tx.test");
if var == nil then
m.log(9, "Don't know what to say...");
return ret
end
if var == "FELIPE"
m.log(9, "Ops.");
elseif var == "felipe"
m.log(9, "Just fine.");
ret ="ok";
else
m.log(9, "Really?");
end
return ret
end

View File

@@ -0,0 +1,19 @@
function main()
ret = nil
num = m.getvar("tx.test");
if num == nil then
m.log(9, "Don't know what to say about this so called number.");
return ret
end
num = tonumber(num)
if num > 1 then
m.log(9, "Number is bigger than one.");
ret = "Whee :)"
else
m.log(9, "Really?");
end
return ret
end

View File

@@ -0,0 +1,21 @@
function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end
function main()
ret = nil
m.log(9, "Here I am");
z = m.getvars("QUERY_STRING");
m.log(9, "Z: " .. dump(z))
return ret
end

View File

@@ -0,0 +1,4 @@
function main()
m.log(9, "echo 123");
return "Lua script matched.";
end

View File

@@ -0,0 +1,5 @@
function main()
m.log(9, "echo 123");
m.setvar("tx.test", "whee");
return "Lua script matched.";
end

View File

@@ -0,0 +1,3 @@
function main()
return "Lua script matched.";
end

View File