以站点的形式加载lua代码

以站点的形式加载lua代码

server {
     listen 80;
     server_name local.net;
     root "z:/a";
     default_type text/html;
     lua_code_cache  off;

      location ~ ^/([-_a-zA-Z0-9/]+){
            set $filen $1;
            access_by_lua_file "$document_root/access_check.lua";
            content_by_lua_file "$document_root/$filen.lua";
        }
}

在access阶段lua中不能出现ngx.say,否则之后的content阶段不会被执行到

--access_by_lua_file.lua
--ngx.say("access ok")   ---不能出现在access_by_lua_file 

--设定模块的加载路径
package.path=package.path .. ngx.var.document_root .. "/mod/?.lua;"

local tools = require("tools")
local args=ngx.req.get_uri_args()

if not args.a or not args.b or not tools.is_number(args.a,args.b) then
    ngx.exit(ngx.HTTP_BAD_REQUEST)
end

你可能感兴趣的:(以站点的形式加载lua代码)