-
Notifications
You must be signed in to change notification settings - Fork 162
Expand file tree
/
Copy pathrpcserver.lua
More file actions
52 lines (39 loc) · 961 Bytes
/
rpcserver.lua
File metadata and controls
52 lines (39 loc) · 961 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
local xavante = require "xavante"
local filehandler = require "xavante.filehandler"
local cgiluahandler = require "xavante.cgiluahandler"
local redirecthandler = require "xavante.redirecthandler"
-- Define here where Xavante HTTP documents scripts are located
local webDir = "./www"
local rules = {
-- redirect
{
match = "^[^%./]*/$",
with = redirecthandler,
params = {"index.lua"}
},
{
match = "^[^%./]*/jsonrpc/?$",
with = redirecthandler,
params = {"jsonrpc.lua"}
},
-- cgi
{
match = {"%.lp$", "%.lp/.*$", "%.lua$", "%.lua/.*$" },
with = cgiluahandler.makeHandler (webDir)
},
-- static content
{
match = ".",
with = filehandler,
params = {baseDir = webDir}
},
}
xavante.HTTP{
server = {host = "*", port = 8080},
defaultHost = {
rules = rules
},
}
print "\nStarting server...\n";
xavante.start();
print "exiting...\n"