Files
http-rs/src/examples/plugins/plugin.lua
T

18 lines
556 B
Lua

-- example plugin for http-rs ; using current api
print("type(router) = " .. type(router))
print("router = ", router)
router:add_file_server("/uploads", "./uploaded_files")
router:add_static("/api/status", 200, '{"status":"ok","version":"1.0"}', "application/json")
print("Lua plugin loaded with the following arguments:")
for i, v in ipairs(args) do
print(" arg[" .. i .. "] = " .. tostring(v))
end
if args[1] == "debug" then
router:add_static("/debug", 200, "Debug mode active", "text/plain")
print("Debug endpoint added at /debug")
end