Authored by chunhua.zhang

add

local http_request = require "http_request"
local switch_controller = require "switch_controller"
--- those methods will be degraded. nginx will send response directly without redirecting to backend servers.
local degrade_methods = {
"method1",
"method2"
}
function do_degrade()
local method = http_request.get_req_param("method")
for i, v in ipairs(degrade_methods) do
if method == v then
ngx.log(ngx.ERR, "method is degraded.", method)
ngx.exit(ngx.HTTP_OK)
end
end
end
function do_direct(redirectPath)
--- processing: api.yoho.cn/operation/get/home?xxxxx
... ... @@ -101,6 +119,11 @@ end
---- main
function main()
local _status, _msg = pcall(do_degrade)
if not _status then
ngx.log(ngx.ERR, "call method [do_degrade] failed.", _msg)
end
local status, ret = pcall(get_redirect_url)
if not status then
ngx.log(ngx.ERR, "call method [get_redirect_url] failed.", ret)
... ...