A lightweight HTTP workers runtime for Lua built on asynchronous I/O.
Write request handlers in Lua and serve them using a high-performance event loop powered by libuv.
function handle(req)
return {
status = 200,
headers = {
["Content-Type"] = "text/plain"
},
body = "Hello, " .. (req.query.name or "world")
}
end- async runtime powered by libuv.
- a secure sandbox with isolate architecture, each LuaState has it's own memory allocator and restricted API calls
- fast secure HTTP parsing with llhttp.
lunar/jsonAPI that uses yyjson under the hood for extreme performance.- simple request/response API.
- minimal dependencies
create hello.lua:
function handle(req)
return {
status = 200,
headers = {
["Content-Type"] = "text/plain"
},
body = "Hello from Lunar!"
}
endrun it:
./lunar hello.luathen visit:
http://localhost:8080
function handle(req)
print(req.method)
print(req.path)
print(req.query.name)
endhandlers return a Lua table describing the HTTP response:
return {
status = 200,
headers = {
["Content-Type"] = "application/json"
},
body = '{"ok":true}'
}lunar is built on:
- libuv for asynchronous networking and the event loop
- llhttp for HTTP/1.1 request parsing
- lua 5.5 for application logic (forked to add sandbox limits and possibly performance improvements over stock 5.5)
git clone https://github.com/colourlabs/lunar
cd lunar
meson setup build
meson compile -C buildrun a Lua worker:
./build/lunar hello.lualunar is currently under active development. APIs may change between releases.