diff options
| author | John Turner <jturner.usa@gmail.com> | 2026-03-05 00:52:03 -0500 |
|---|---|---|
| committer | John Turner <jturner.usa@gmail.com> | 2026-03-05 00:52:03 -0500 |
| commit | 92e8d4947de614a67fed6709a59365de98705b35 (patch) | |
| tree | 981213f1ed73c88834f9ec3fe7c9b1b8f3e19211 /config.lua | |
| parent | 583a62c4a2ac6137134d50f70ff8ad546ac4b2a1 (diff) | |
| download | httpd-92e8d4947de614a67fed6709a59365de98705b35.tar.gz | |
impl Lua handler
Diffstat (limited to 'config.lua')
| -rw-r--r-- | config.lua | 25 |
1 files changed, 20 insertions, 5 deletions
@@ -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 |
