Skip to content

Commit ca438ef

Browse files
committed
Add full API definition for lua-nginx-module
This is based on the v 0.10.10 API. For clarity the API definition has been moved to a separate file.
1 parent cb8fdb7 commit ca438ef

File tree

4 files changed

+147
-6
lines changed

4 files changed

+147
-6
lines changed

install.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ for _, filename in ipairs {
110110
"inline_options.lua",
111111
"builtin_standards.lua",
112112
"love_standard.lua",
113+
"ngx_standard.lua",
113114
"expand_rockspec.lua",
114115
"multithreading.lua",
115116
"cache.lua",

luacheck-scm-1.rockspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ build = {
4040
["luacheck.lua_fs"] = "src/luacheck/lua_fs.lua",
4141
["luacheck.main"] = "src/luacheck/main.lua",
4242
["luacheck.multithreading"] = "src/luacheck/multithreading.lua",
43+
["luacheck.ngx_standard"] = "src/luacheck/ngx_standard.lua",
4344
["luacheck.options"] = "src/luacheck/options.lua",
4445
["luacheck.parser"] = "src/luacheck/parser.lua",
4546
["luacheck.reachability"] = "src/luacheck/reachability.lua",

src/luacheck/builtin_standards.lua

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,7 @@ lua_defs.luajit = add_defs(make_min_def("luajit"), {
254254
unpack = empty
255255
}
256256
})
257-
lua_defs.ngx_lua = add_defs(lua_defs.luajit, {
258-
fields = {
259-
ngx = {other_fields = true, read_only = false},
260-
ndk = {other_fields = true}
261-
}
262-
})
257+
lua_defs.ngx_lua = add_defs(lua_defs.luajit, require "luacheck.ngx_standard")
263258
lua_defs.max = add_defs(lua_defs.lua51c, lua_defs.lua52c, lua_defs.lua53c, lua_defs.luajit)
264259

265260
for name, def in pairs(lua_defs) do

src/luacheck/ngx_standard.lua

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
local empty = {}
2+
3+
local function def_fields(...)
4+
local fields = {}
5+
6+
for _, field in ipairs({...}) do
7+
fields[field] = empty
8+
end
9+
10+
return {fields = fields}
11+
end
12+
13+
return {
14+
fields = {
15+
ngx = {
16+
fields = {
17+
arg = {other_fields = true, read_only = false},
18+
var = {other_fields = true, read_only = false},
19+
OK = empty,
20+
AGAIN = empty,
21+
DONE = empty,
22+
DECLINED = empty,
23+
null = empty,
24+
HTTP_GET = empty,
25+
HTTP_HEAD = empty,
26+
HTTP_PUT = empty,
27+
HTTP_POST = empty,
28+
HTTP_DELETE = empty,
29+
HTTP_OPTIONS = empty,
30+
HTTP_MKCOL = empty,
31+
HTTP_COPY = empty,
32+
HTTP_MOVE = empty,
33+
HTTP_PROPFIND = empty,
34+
HTTP_PROPPATCH = empty,
35+
HTTP_LOCK = empty,
36+
HTTP_UNLOCK = empty,
37+
HTTP_PATCH = empty,
38+
HTTP_TRACE = empty,
39+
HTTP_CONTINUE = empty,
40+
HTTP_SWITCHING_PROTOCOLS = empty,
41+
HTTP_OK = empty,
42+
HTTP_CREATED = empty,
43+
HTTP_ACCEPTED = empty,
44+
HTTP_NO_CONTENT = empty,
45+
HTTP_PARTIAL_CONTENT = empty,
46+
HTTP_SPECIAL_RESPONSE = empty,
47+
HTTP_MOVED_PERMANENTLY = empty,
48+
HTTP_MOVED_TEMPORARILY = empty,
49+
HTTP_SEE_OTHER = empty,
50+
HTTP_NOT_MODIFIED = empty,
51+
HTTP_TEMPORARY_REDIRECT = empty,
52+
HTTP_BAD_REQUEST = empty,
53+
HTTP_UNAUTHORIZED = empty,
54+
HTTP_PAYMENT_REQUIRED = empty,
55+
HTTP_FORBIDDEN = empty,
56+
HTTP_NOT_FOUND = empty,
57+
HTTP_NOT_ALLOWED = empty,
58+
HTTP_NOT_ACCEPTABLE = empty,
59+
HTTP_REQUEST_TIMEOUT = empty,
60+
HTTP_CONFLICT = empty,
61+
HTTP_GONE = empty,
62+
HTTP_UPGRADE_REQUIRED = empty,
63+
HTTP_TOO_MANY_REQUESTS = empty,
64+
HTTP_CLOSE = empty,
65+
HTTP_ILLEGAL = empty,
66+
HTTP_INTERNAL_SERVER_ERROR = empty,
67+
HTTP_METHOD_NOT_IMPLEMENTED = empty,
68+
HTTP_BAD_GATEWAY = empty,
69+
HTTP_SERVICE_UNAVAILABLE = empty,
70+
HTTP_GATEWAY_TIMEOUT = empty,
71+
HTTP_VERSION_NOT_SUPPORTED = empty,
72+
HTTP_INSUFFICIENT_STORAGE = empty,
73+
STDERR = empty,
74+
EMERG = empty,
75+
ALERT = empty,
76+
CRIT = empty,
77+
ERR = empty,
78+
WARN = empty,
79+
NOTICE = empty,
80+
INFO = empty,
81+
DEBUG = empty,
82+
ctx = {other_fields = true, read_only = false},
83+
location = def_fields("capture", "capture_multi"),
84+
status = {read_only = false},
85+
header = {other_fields = true, read_only = false},
86+
resp = def_fields("get_headers"),
87+
req = def_fields("is_internal", "start_time", "http_version", "raw_header",
88+
"get_method", "set_method", "set_uri", "set_uri_args", "get_uri_args",
89+
"get_post_args", "get_headers", "set_header", "clear_header", "read_body",
90+
"discard_body", "get_body_data", "get_body_file", "set_body_data",
91+
"set_body_file", "init_body", "append_body", "finish_body", "socket"),
92+
exec = empty,
93+
redirect = empty,
94+
send_headers = empty,
95+
headers_sent = empty,
96+
print = empty,
97+
say = empty,
98+
log = empty,
99+
flush = empty,
100+
exit = empty,
101+
eof = empty,
102+
sleep = empty,
103+
escape_uri = empty,
104+
unescape_uri = empty,
105+
encode_args = empty,
106+
decode_args = empty,
107+
encode_base64 = empty,
108+
decode_base64 = empty,
109+
crc32_short = empty,
110+
crc32_long = empty,
111+
hmac_sha1 = empty,
112+
md5 = empty,
113+
md5_bin = empty,
114+
sha1_bin = empty,
115+
quote_sql_str = empty,
116+
today = empty,
117+
time = empty,
118+
now = empty,
119+
update_time = empty,
120+
localtime = empty,
121+
utctime = empty,
122+
cookie_time = empty,
123+
http_time = empty,
124+
parse_http_time = empty,
125+
is_subrequest = empty,
126+
re = def_fields("match", "find", "gmatch", "sub", "gsub"),
127+
shared = {other_fields = true, read_only = false},
128+
socket = def_fields("udp", "tcp", "connect"),
129+
get_phase = empty,
130+
thread = def_fields("spawn", "wait", "kill"),
131+
on_abort = empty,
132+
timer = def_fields("at", "every", "running_count", "pending_count"),
133+
config = def_fields("subsystem", "debug", "prefix", "nginx_version",
134+
"nginx_configure", "ngx_lua_version"),
135+
worker = def_fields("pid", "count", "id"),
136+
},
137+
},
138+
ndk = {
139+
fields = {
140+
set_var = {other_fields = true},
141+
},
142+
},
143+
},
144+
}

0 commit comments

Comments
 (0)