30 lines
612 B
Lua
30 lines
612 B
Lua
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 |