summaryrefslogtreecommitdiffstats
path: root/extjsdemo-controller.lua
blob: 6a7a13e62506209b2b106ad53e44227f90475865 (plain)
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
-- ipsec controller

module(..., package.seeall)

require("posix")
require("json")

function test(self)
	local a = {}
--	a.path = posix.cwd()
	return a
end

-- quick and dirty json resolver. could be done with viewtype?
-- anyway... the file would be a oneliner anyway...
local function json_resolver(self)
	io.write("\n\n"..json.encode(self).."\n")
end

function submit(self)
	-- overwrite resolver. quick and dirty...
	view_resolver = function(self) 
		return json_resolver
	end

	local ret = {}

	-- only validation here is we test if mask is 'aaa'
	if self.clientdata.mask == "aaa" then
		ret.success = false
		ret.errors = { mask = "'aaa' is a netmask...?" }
	else
		ret.success = true
	end

	return ret
end

function load(self)
	-- overwrite resolver. quick and dirty...
	view_resolver = function(self) 
		return json_resolver
	end

	local ret = {}
	-- we must define 'success' and 'data' fields
	ret.success = "true"
	ret.data = { address = "1.2.3.4", mask = "255.255.255.0" }
	return ret
end