openresty capture

local args = {}
args["name"] = "张三"
args["sex"] = ""

local captureRes;
if ngx.var.request_method == "POST" then
    captureRes = ngx.location.capture('/dsideal_yy/test', {method = ngx.HTTP_POST, headers = { ["Content-Type"] = "application/x-www-form-urlencoded" }, body = ngx.encode_args(args)})
else
    captureRes = ngx.location.capture('/dsideal_yy/test', {method = ngx.HTTP_GET, args = args})
end

if captureRes.status == 200 then
    local ret = cjson.decode(captureRes.body)
end

 

posted @ 2018-02-01 10:02  缤纷世界  阅读(373)  评论(0编辑  收藏  举报