/
test_server.lua
70 lines (57 loc) · 942 Bytes
/
test_server.lua
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
local backend = arg[1]
local mode = arg[2] or 'rw'
local option = arg[3]
local config = {}
if option then
if option == 'ssl' then
config.sslparams = require'test_ssl_config'.server
end
end
config.write_access = mode:find('w') ~= nil
config.read_access = mode:find('r') ~= nil
add =
function(a,b)
return a+b
end
echo =
function(...)
return ...
end
strerror =
function()
error('testmessage')
end
customerror =
function(err)
error(err)
end
nested = {
method = {
name = function()return true end
}
}
person =
function(name)
local p = {
_name = name
}
function p:name(name)
if name then
self._name = name
else
return self._name
end
end
return p
end
double_x =
function()
return 2*x
end
data = {
x = 0,
y = 3
}
local tango = require'tango'
local server = tango.server[backend]
server.loop(config)