This commit is contained in:
parent
fc813709d4
commit
e625b8b416
|
|
@ -7,16 +7,24 @@ local json = require "cjson"
|
|||
|
||||
|
||||
function _M.new(cpath, rpath)
|
||||
ngx.log(ngx.ERR,"read:"..cpath..",rpath:"..rpath)
|
||||
-- ngx.log(ngx.ERR,"read:"..cpath..",rpath:"..rpath)
|
||||
local self = {
|
||||
cpath = cpath,
|
||||
rpath = rpath,
|
||||
config = '',
|
||||
site_config = ''
|
||||
}
|
||||
local p = setmetatable(self, mt)
|
||||
return p
|
||||
end
|
||||
|
||||
|
||||
function _M.setConfData( self, config, site_config )
|
||||
self.config = config
|
||||
self.site_config = site_config
|
||||
end
|
||||
|
||||
|
||||
|
||||
function _M.return_message(self, status, msg)
|
||||
ngx.header.content_type = "application/json;"
|
||||
|
|
@ -34,7 +42,7 @@ function _M.return_html(self,status,html)
|
|||
end
|
||||
|
||||
function _M.read_file_body(self, filename)
|
||||
ngx.log(ngx.ERR,"read_file_body:"..filename)
|
||||
-- ngx.log(ngx.ERR,"read_file_body:"..filename)
|
||||
fp = io.open(filename, 'r')
|
||||
if fp == nil then
|
||||
return nil
|
||||
|
|
@ -47,6 +55,17 @@ function _M.read_file_body(self, filename)
|
|||
return fbody
|
||||
end
|
||||
|
||||
function _M.continue_key(self,key)
|
||||
key = tostring(key)
|
||||
if string.len(key) > 64 then return false end;
|
||||
local keys = {"content","contents","body","msg","file","files","img","newcontent"}
|
||||
for _,k in ipairs(keys)
|
||||
do
|
||||
if k == key then return false end;
|
||||
end
|
||||
return true;
|
||||
end
|
||||
|
||||
|
||||
function _M.array_len(self, arr)
|
||||
if not arr then return 0 end
|
||||
|
|
@ -98,6 +117,10 @@ function _M.read_file(self, name)
|
|||
return json.decode(fbody)
|
||||
end
|
||||
|
||||
function _M.read_file_table( self, name )
|
||||
return self:select_rule(self:read_file('args'))
|
||||
end
|
||||
|
||||
function _M.t(self)
|
||||
ngx.say(',,,')
|
||||
end
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ ngx.header.content_type = "text/plain"
|
|||
local config = C:read_file_body_decode(cpath .. 'config.json')
|
||||
local site_config = C:read_file_body_decode(cpath .. 'site.json')
|
||||
|
||||
C.setConfData(config, site_config)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -76,7 +78,7 @@ function get_server_name()
|
|||
return c_name
|
||||
end
|
||||
|
||||
local args_rules = C:select_rule(C:read_file('args'))
|
||||
local args_rules = C:read_file_table('args')
|
||||
|
||||
local retry = config['retry']
|
||||
local retry_time = config['retry_time']
|
||||
|
|
@ -85,18 +87,7 @@ local ip
|
|||
local server_name
|
||||
|
||||
|
||||
function continue_key(key)
|
||||
key = tostring(key)
|
||||
if string.len(key) > 64 then return false end;
|
||||
local keys = {"content","contents","body","msg","file","files","img","newcontent"}
|
||||
for _,k in ipairs(keys)
|
||||
do
|
||||
ngx.say(k..'---'..key)
|
||||
if k == key then return false end;
|
||||
end
|
||||
ngx.say('ok:'..key)
|
||||
return true;
|
||||
end
|
||||
|
||||
|
||||
function is_ngx_match(rules,sbody,rule_name)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue