fix exit status issue
This commit is contained in:
@@ -10,7 +10,6 @@ local function get_access_token()
|
|||||||
local host = ngx.var.host
|
local host = ngx.var.host
|
||||||
local wx_domain = ngx.var.wx_domain
|
local wx_domain = ngx.var.wx_domain
|
||||||
|
|
||||||
ngx.log(ngx.INFO, "Request URL -> ", ngx.var.uri)
|
|
||||||
ngx.log(ngx.INFO, "HTYUC -> ", htyuc)
|
ngx.log(ngx.INFO, "HTYUC -> ", htyuc)
|
||||||
ngx.log(ngx.INFO, "Host -> ", host)
|
ngx.log(ngx.INFO, "Host -> ", host)
|
||||||
ngx.log(ngx.INFO, 'HtyHostHeader -> ', htyhostHeader)
|
ngx.log(ngx.INFO, 'HtyHostHeader -> ', htyhostHeader)
|
||||||
@@ -36,6 +35,7 @@ local function get_access_token()
|
|||||||
if no_exception == true then
|
if no_exception == true then
|
||||||
if 200 ~= resp.status then
|
if 200 ~= resp.status then
|
||||||
ngx.log(ngx.ERR, "GET ACCESS TOKEN *FAILED*", pl.write(resp_err))
|
ngx.log(ngx.ERR, "GET ACCESS TOKEN *FAILED*", pl.write(resp_err))
|
||||||
|
ngx.status = resp.status
|
||||||
ngx.say(pl.write(resp_err))
|
ngx.say(pl.write(resp_err))
|
||||||
ngx.exit(resp.status)
|
ngx.exit(resp.status)
|
||||||
else
|
else
|
||||||
@@ -47,7 +47,10 @@ local function get_access_token()
|
|||||||
resp = ""
|
resp = ""
|
||||||
end
|
end
|
||||||
ngx.log(ngx.ERR, "FAILED TO CONNECT TO *HTYUC*: httpc throws runtime error, please check HTYUC log. / ", pl.write(resp))
|
ngx.log(ngx.ERR, "FAILED TO CONNECT TO *HTYUC*: httpc throws runtime error, please check HTYUC log. / ", pl.write(resp))
|
||||||
ngx.say(pl.write(resp))
|
-- 必须先设置ngx.status,否则ngx.say之后就直接被设置为200了,不会再被exit设为401
|
||||||
|
-- https://github.com/openresty/lua-resty-redis/issues/15
|
||||||
|
ngx.status = 401
|
||||||
|
ngx.say(cjson.encode({r = false, d = "HtySudoerTokenErr"}))
|
||||||
ngx.exit(401)
|
ngx.exit(401)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -64,12 +67,14 @@ local function get_wx_media(media_id)
|
|||||||
|
|
||||||
if resp == nil then
|
if resp == nil then
|
||||||
ngx.log(ngx.ERR, "FAILED TO CONNECT TO *Weixin*", req_err)
|
ngx.log(ngx.ERR, "FAILED TO CONNECT TO *Weixin*", req_err)
|
||||||
|
ngx.status = 500
|
||||||
ngx.say(req_err)
|
ngx.say(req_err)
|
||||||
ngx.exit(500)
|
ngx.exit(500)
|
||||||
end
|
end
|
||||||
|
|
||||||
if 200 ~= resp.status then
|
if 200 ~= resp.status then
|
||||||
ngx.log(ngx.ERR, 'GET WECHET MEDIA *FAILED*', req_err)
|
ngx.log(ngx.ERR, 'GET WECHET MEDIA *FAILED*', req_err)
|
||||||
|
ngx.status = resp.status
|
||||||
ngx.say(req_err)
|
ngx.say(req_err)
|
||||||
ngx.exit(resp.status)
|
ngx.exit(resp.status)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user