With the first implementation of mod_cml and later mod_magnet smart users asked why we don’t use lua also as config language for lighttpd.
Up to now I was pushing back and saying that a huge change in the configfile would make upgraders very unhappy as they would have to rewrite the config files. Looking at what we have for 1.5.0 right now, we need tweaks anyway.
This always happens if you rip a thing apart: you see more things that should be cleaned up. My first experiments are a bit done:
server = { name = "my.example.org", modules = { "mod_indexfile" }, ["errorfile-prefix"] = "foobar", } sockets = { [":80"] = { server = { name = "foo.example.org" }, HTTP = { url = function(url) if url == "foo" then server.name = "baz.example.org" end end }, } } sockets[":80"].HTTP.url("foo") print(server.name)
This is a first idea. It shows how the LUA syntax isn’t sooo different from our current config syntax.
- The global variables, stay global as now.
- socket conditionals is now a simple array of sockets
- conditionals are functions, now you can do what you want with it
I hope that I can handle the full config syntax into this structure. For now it is looks more appealing that ripping the old config-parser code apart and turn it into glib-notation. With all the conditionals and types we basicly have implemented our own scripting language.
Let’s see where this leads too.