Lua API: New API: set_error404_cb

Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>
This commit is contained in:
Jianhui Zhao committed 2018-07-19 14:03:14 +08:00
1 parent dcb397a62c
commit c6441851f6
4 files changed
+72 -28

No files matched your search

+10
View File
@@ -34,6 +34,16 @@ local srv = uh.new(port)
print("Listen on:", port)
srv:set_error404_cb(function(cl, opt)
uh.send_header(cl, 200, "OK", -1)
uh.append_header(cl, "Myheader", "Hello")
uh.header_end(cl)
uh.chunk_send(cl, "<h1>Libuhttpd-Lua: Not found</h1>")
uh.request_done(cl)
end)
srv:add_action("/lua", function(cl, opt)
uh.send_header(cl, 200, "OK", -1)
uh.append_header(cl, "Myheader", "Hello")