forked from loicortola/nodemcu-espress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
http_response.lua
34 lines (30 loc) · 906 Bytes
/
http_response.lua
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
return function(conn)
------------------------------------------------------------------------------
-- add header (should be called before send)
------------------------------------------------------------------------------
local addheader = function(res, name, value)
local h = res.headers
h[name] = value
end
------------------------------------------------------------------------------
-- send response
------------------------------------------------------------------------------
local send = function(res, data, status)
local f = loadfile("http_response_send.lc")
f()(res, data, status)
f = nil
end
local sendfile = function(res, filename, status)
local f = loadfile("http_response_sendfile.lc")
f()(res, filename, status)
f = nil
end
return {
conn = conn,
headers = {},
addheader = addheader,
send = send,
sendfile = sendfile,
statuscode = 200
}
end