-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathloader.lua
More file actions
55 lines (44 loc) · 1.21 KB
/
loader.lua
File metadata and controls
55 lines (44 loc) · 1.21 KB
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
#!/usr/bin/env luajit
ngx = require('ngx')
ngx.var = {
MOOCHINE_APP_PATH = os.getenv('PWD'),
MOOCHINE_APP_NAME = 'test',
HADDIT_APP_PATH = os.getenv('HADDIT_HOME') .. '/luasrc',
HADDIT_CONFIG = os.getenv('PWD') .. '/conf/haddit.config',
request_method = 'GET',
REQUEST_URI = arg[1] or error('no target uri given'),
arg = arg,
}
local E = require('datautil.escape')
ngx.req = {
get_headers = function()
return {}
end,
get_uri_args = function()
local uri = ngx.var.REQUEST_URI
local s = uri:find('?', nil, true)
if s == nil then
return {}
else
local q = uri:sub(s+1)
return E.parseQuery(q)
end
end,
}
local mydir = arg[0]:gsub('/[^/]+$', '')
local ffi = require('ffi')
-- keep the reference in L
local L = ffi.load('crypto', true)
local L2 = ffi.load(mydir .. '/libngxc.so', true)
local cosocket = require('everlooping.tcppool')
local ioloop = require('everlooping.ioloop')
local entryfile = os.getenv('MOOCHINE_HOME') .. '/luasrc/mch_content.lua'
cosocket.register(function()
assert(loadfile(entryfile))()
print('Headers:')
for k, v in pairs(ngx.header) do
print(k .. ': ' .. v)
end
ioloop.defaultIOLoop():stop()
end)
ioloop.defaultIOLoop():start()