Authored by chunhua.zhang

bug fix

@@ -44,7 +44,7 @@ function do_degrade() @@ -44,7 +44,7 @@ function do_degrade()
44 local method = http_request.get_req_param("method") 44 local method = http_request.get_req_param("method")
45 45
46 if limit_ip_config and limit_ip_config.degrade_methods then 46 if limit_ip_config and limit_ip_config.degrade_methods then
47 - if limit_ip_config.degrade_methods[method]~=nil then 47 + if contains(limit_ip_config.degrade_methods,method) then
48 ngx.log(ngx.ERR, "method is degraded.", method) 48 ngx.log(ngx.ERR, "method is degraded.", method)
49 ngx.header["Content-Type"]="application/json;charset=utf-8" 49 ngx.header["Content-Type"]="application/json;charset=utf-8"
50 local rsp_body = '{"code":9999991,"message":"limited"}' 50 local rsp_body = '{"code":9999991,"message":"limited"}'
@@ -54,6 +54,13 @@ function do_degrade() @@ -54,6 +54,13 @@ function do_degrade()
54 end 54 end
55 end 55 end
56 56
  57 +function contains(t, e)
  58 + for i = 1,#t do
  59 + if t[i] == e then return true end
  60 + end
  61 + return false
  62 +end
  63 +
57 -------- function: doing rate limit by key[interface]----- 64 -------- function: doing rate limit by key[interface]-----
58 function rate_limit() 65 function rate_limit()
59 66