Thoughts on a Lua middleware

I’m hacking together a LuaJIT middleware for Caddy, in the vein of OpenResty[1]/lua-nginx-module[2] for nginx, built on Luar[3] and golua[4]. But I just noticed that official (listed) Caddy plugins can’t use cgo [5], so I figured I’d write to gauge interest and ask for others’ thoughts/feedback/ideas out of curiosity.

If others aren’t interested I’ll still develop it for myself, but if there is interest I might be willing to maintain a simple downstream Caddy fork (which, coincidentally, is also how OpenResty is maintained). I’m also (a little bit less) interested in making a middleware with a pure-Go Lua implementation (Shopify/go-lua[6] or gopher-lua[7]), and would be interested in others’ thoughts here as well.


* Sorry for the non-links, apparently Discourse doesn’t let new users post more than 2 links/post.

Have you seen GitHub - caddyserver/caddy-lua: An experiment in executing Lua from Caddy. Ignore this for now. ;) ? Related but probably not quite the same.

Oh cool! Not sure how I missed that.

It looks like that package is mostly for HTML templating in Lua, yeah? I’m working towards something a bit more general-purpose. But I see it’s using gopher-lua, and it’s implemented as middleware, so maybe I can steal some code and contribute a bit back to that repo if there’s any interest in resurrecting it.

Correct, that project is more of a pie-in-the-sky dream of replacing PHP with in-process Lua.

I’m not super fond of the idea of scripting Caddy. I mean, don’t let me stop you – but I think an ideal integration of Lua with Caddy would be more of a wrapper over Caddy or over the Caddyfile so that one is dynamically generated.