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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
local common = require("common")
---@meta
---@class net
local net = {}
---@class server-table
local server_table = {}
---@class res-table
local res_table = {}
---sends value to client and closes socket
---@param T res-table
---@param value string
function res_table.send(T, value) end
---autosets Content-Type and sends contents of file to client and closes socket
---@param T res-table
---@param value string
function res_table.sendfile(T, value) end
---sends value to client and doesn't close the socket
---@param T res-table
---@param value string
function res_table.write(T, value) end
---closes socket
---@param T res-table
function res_table.close(T) end
---prevents calling any other selected routes
---@param T res-table
function res_table.stop(T) end
---key value table containing header values to be sent
res_table.header = {}
---@class req-table
local req_table = {}
---"roll" the request forward
---@param T req-table
---@param bytes integer | nil
function req_table.roll(T, bytes) end
---list of parameters in route
req_table.parameters = {}
---@deprecated
req_table.client_fd = 0
---@deprecated
req_table._bytes = 0
---@type integer
req_table.ip = 0
---@type string
req_table.Body = ""
---@type any|nil
req_table.files = {}
---@type any|nil
req_table.cookies = {}
---@param T server-table
---@param route string
---@param callback fun(res: res-table, req: req-table)
function server_table.GET(T, route, callback) end
---@param T server-table
---@param route string
---@param callback fun(res: res-table, req: req-table)
function server_table.HEAD(T, route, callback) end
---@param T server-table
---@param route string
---@param callback fun(res: res-table, req: req-table)
function server_table.POST(T, route, callback) end
---@param T server-table
---@param route string
---@param callback fun(res: res-table, req: req-table)
function server_table.PUT(T, route, callback) end
---@param T server-table
---@param route string
---@param callback fun(res: res-table, req: req-table)
function server_table.DELETE(T, route, callback) end
---@param T server-table
---@param route string
---@param callback fun(res: res-table, req: req-table)
function server_table.CONNECT(T, route, callback) end
---@param T server-table
---@param route string
---@param callback fun(res: res-table, req: req-table)
function server_table.OPTIONS(T, route, callback) end
---@param T server-table
---@param route string
---@param callback fun(res: res-table, req: req-table)
function server_table.TRACE(T, route, callback) end
---@param T server-table
---@param route string
---@param callback fun(res: res-table, req: req-table)
function server_table.PATCH(T, route, callback) end
---@param T server-table
---@param route string
---@param callback fun(res: res-table, req: req-table)
function server_table.all(T, route, callback) end
---@param server server-table
local function listen_callback(server) end
---@param callback fun(server: server-table)
---@param port integer
function net.listen(callback, port) end
---@class request-return
---@field content stream
---creates an https request
---@param url string
---@param value string | nil
---@param header table<string, string> | nil
---@param request string | nil
---@return request-return | error
function net.srequest(url, value, header, request) end
---@class wss-table
local wss = {}
---@class wss-read
local wss_read = {}
---@type string
wss_read.content = ""
---@type integer
wss_read.opcode = 0
---reads oldest unread frame from server
---@param T wss-table
---@return wss-read | error
function wss.read(T) end
---sents data frame to server
---@param T wss-table
---@param data string
---@return nil | error
function wss.write(T, data) end
---calls gc early
---@param T wss-table
---@return nil
function wss.close(T) end
---creates a wss connection
---@param url string
---@return wss-table | error
function net.wss(url) end
return net
|