糖果实验室杂货铺

Candy Lab

Blues框架如何取得请求者的Rquest信息

5 months ago 0

Blues框架如何取得请求者的Rquest信息

在request.lua下引用nginx.lua这个lazytable库。

None
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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

None
1
2
3
4
5
6
app:get("/blues", function(request,id)
    for k,v in pairs(request.params) do
        ngx.say(k)
    end 
    return {k='key', v='value'}
end)

糖果实验室

Openresty中文编程网
IKBC经典机械键盘
机械键盘领券优惠购买

Write a Comment