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)

糖果

糖果
LUA从入门到放弃

Tweyseo Walkonluajit 1

# **0. 背景**## **a. 目的**这里主要研究LuaJIT的Trace的相关原理,并且展示如何使用LuaJIT提供的[v.lua](https://github.com/LuaJIT/LuaJIT/blob/master/src/jit/v.lua)和[dump...… Continue reading

Nginx+Lua中文WIKI

Published on March 14, 2019