Docunext


Some Example Lua Code

February 10th, 2011

Lua is a perfect scripting language for quick and lightweight logic - for proxies, middleware applications, and application level routing.

I wrote this small lua script as a test for redirecting one domain host to another:

json = require("json")
testString = [[ { "example.com": "example.org" } ]]
o = json.decode(testString)
table.foreach(o,print)
myhost = lighty.request["Host"]
if (o[myhost]) then
    lighty.header["Location"] = "http://www." .. o[myhost]
    return 301
end
Yearly Indexes: 2003 2004 2006 2007 2008 2009 2010 2011 2012 2013 2015 2019 2020 2022