summaryrefslogtreecommitdiff
path: root/config.lua
diff options
context:
space:
mode:
authorJohn Turner <jturner.usa@gmail.com>2026-03-05 00:52:03 -0500
committerJohn Turner <jturner.usa@gmail.com>2026-03-05 00:52:03 -0500
commit92e8d4947de614a67fed6709a59365de98705b35 (patch)
tree981213f1ed73c88834f9ec3fe7c9b1b8f3e19211 /config.lua
parent583a62c4a2ac6137134d50f70ff8ad546ac4b2a1 (diff)
downloadhttpd-92e8d4947de614a67fed6709a59365de98705b35.tar.gz
impl Lua handler
Diffstat (limited to 'config.lua')
-rw-r--r--config.lua25
1 files changed, 20 insertions, 5 deletions
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