local xavante = require "xavante"
local filehandler = require "xavante.filehandler"
local wsx = require "wsapi.xavante"
-- Define here where Xavante HTTP documents scripts are located
local webDir = "/home/audibert/testXavante/xavante"
local simplerules = {
{
match = "call1",
with = wsx.makeHandler(function1),
},
{
match = "call2",
with = wsx.makeHandler(function2),
},
{ -- WSAPI application will be mounted under /app
match = { "%.lua$", "%.lua/" },
with = wsx.makeGenericHandler(webDir)
},
{ -- filehandler
match = ".",
with = filehandler,
params = {baseDir = webDir}
},
}
function function1()
print("Call 1")
end
function function2()
print("Call 2")
end
-- Displays a message in the console with the used ports
xavante.start_message(function (ports)
local date = os.date("[%Y-%m-%d %H:%M:%S]")
print(string.format("%s Xavante started on port(s) %s",
date, table.concat(ports, ", ")))
end)
xavante.HTTP{
server = {host = "*", port = 8080},
defaultHost = {
rules = simplerules
},
}
function callback()
print(os.date())
return false
end
xavante.start()