@@ -18,23 +18,12 @@ int ngx_http_lua_var_ffi_remote_addr(ngx_http_request_t *r,
1818
1919
2020local var_patched = pcall (function () return C .ngx_http_lua_var_ffi_test () end )
21- local _M = {
22- _version = 0.1 ,
21+ local vars = {
2322 method = ngx .req .get_method ,
2423}
2524
2625
27- function _M ._request ()
28- local r = get_request ()
29- if not r then
30- return false , " no request found"
31- end
32-
33- return r
34- end
35-
36-
37- function _M .uri (r )
26+ function vars .uri (r )
3827 r = r or get_request ()
3928 if not r then
4029 return false , " no request found"
@@ -45,7 +34,7 @@ function _M.uri(r)
4534end
4635
4736
48- function _M .host (r )
37+ function vars .host (r )
4938 r = r or get_request ()
5039 if not r then
5140 return false , " no request found"
@@ -56,12 +45,12 @@ function _M.host(r)
5645end
5746
5847
59- function _M .status ()
48+ function vars .status ()
6049 return ngx .status
6150end
6251
6352
64- function _M .remote_addr (r )
53+ function vars .remote_addr (r )
6554 r = r or get_request ()
6655 if not r then
6756 return false , " no request found"
@@ -72,12 +61,30 @@ function _M.remote_addr(r)
7261end
7362
7463
75- return function (name , request )
76- local method = _M [name ]
64+ local _M = {
65+ _version = 0.1 ,
66+ }
67+
68+
69+ function _M .request ()
70+ local r = get_request ()
71+ if not r then
72+ return false , " no request found"
73+ end
74+
75+ return r
76+ end
77+
78+
79+ function _M .fetch (name , request )
80+ local method = vars [name ]
7781
7882 if not var_patched or not method then
7983 return ngx_var [name ]
8084 end
8185
8286 return method (request )
8387end
88+
89+
90+ return _M
0 commit comments