1
0

init commit

This commit is contained in:
2022-11-01 23:31:14 +08:00
commit 57c2c6a22e
26 changed files with 2208 additions and 0 deletions

30
plugins/request.lua Normal file
View File

@@ -0,0 +1,30 @@
local encode_json = require("core.json").encode
local concat_tab = table.concat
local _M = { version = 0.1 }
function _M.header(ctx, name)
return ctx.headers:get(name)
end
function _M.set_header(ctx, name, value)
return ctx.headers:replace(name, value)
end
function _M.get_ip(ctx)
return ctx.var.remote_addr or ctx.headers:get("x-forwarded-for")
end
function _M.getbody(max_size, ctx)
return ctx.body:getBytes(0, max_size)
end
function _M.get_scheme(ctx)
return ctx.headers:get(":scheme")
end
function _M.get_host(ctx)
return ctx.headers:get(":authority")
end
return _M