Tools

  • Use lj-releng or luacheck to identify global variable references.

Tips

  1. You can cache ngx to a local variable.
local ngx = ngx
  1. Always include _VERSION in your module. For example, in the conn module,
local _M = {
  _VERSION = "0.0.1"
}
 
local mt = { __index = _M }
 
function _M.new(options)
  local self = { ... }
  return setmetatable(self, mt)
end
 
function _M.access(self, remote_addr)
  ...
end
 
return _M
  1. You can call the preceding functions via require('conn').new({}) and filter:access(remote_addr) where filter is an object of conn.