-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathnginx.conf
48 lines (41 loc) · 1.07 KB
/
nginx.conf
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
daemon off;
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
lua_code_cache off;
lua_package_path "/code/lib/?.lua;;";
server {
listen 80;
location / {
default_type text/html;
content_by_lua '
local r3router = require "resty.r3";
-- foo handler
function foo(tokens, params)
ngx.say("fooooooooooooooooooooooo")
ngx.say("tokens:" .. table.concat(tokens, ","))
for key, value in pairs(params) do
ngx.say("param:" .. key .. "=" .. value)
end
end
-- r3router
local r = r3router.new({
{"GET", "/", function(tokens, params) ngx.say("hello r3!") end },
{"GET", "/foo", foo},
{{"GET","POST"}, "/foo/{id}/{name}", foo},
})
-- dispatcher
local ok = r:dispatch_ngx()
if ok then
ngx.status = 200
else
ngx.status = 404
ngx.print("Not found")
end
';
}
}
}