Blues框架如何取得请求者的Rquest信息
Blues框架如何取得请求者的Rquest信息
在request.lua下引用nginx.lua这个lazytable库。
local params = require "nginx"
function Request:getInstance()
local name = "request"
local instance = {
url="/request",
getName = function()
lp("CRequest!")
end
}
instance.uri = "candy lab"
instance.params = params
setmetatable(instance, { __index = self,
__call = function()
lp("Initial Instance")
end
})
return instance
end
app.lua
app:get("/blues", function(request,id)
for k,v in pairs(request.params) do
ngx.say(k)
end
return {k='key', v='value'}
end)