From 92e8d4947de614a67fed6709a59365de98705b35 Mon Sep 17 00:00:00 2001 From: John Turner Date: Thu, 5 Mar 2026 00:52:03 -0500 Subject: impl Lua handler --- config.lua | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'config.lua') diff --git a/config.lua b/config.lua index 6ca8ff5..ea370a9 100644 --- a/config.lua +++ b/config.lua @@ -1,13 +1,28 @@ http = {} http.bind = "localhost:8080" +http.root = "/tmp/www" http.handlers = {} http.handlers["GET"] = function(request) - return { - handler = "staticfile", - path = "/tmp/foo.txt", - mime = "text/plain" - } + if string.match(request.path, "^/lua") then + local payload = "hello world" + + return { + handler = "lua", + status = 200, + content = payload, + headers = { + ["content-type"] = "text/plain", + ["content-length"] = tostring(#payload) + } + } + else + return { + handler = "staticfile", + path = string.format("%s/%s", http.root, request.path), + mime = "text/plain" + } + end end -- cgit v1.2.3