Authored by chunhua.zhang

bug fix for below:

---------

...cal/openresty-1.9.15.1/nginx/conf/lua/limit_api_flow.lua: in function 'rate_limit'
	...cal/openresty-1.9.15.1/nginx/conf/lua/limit_api_flow.lua:98: in function <...cal/openresty-1.9.15.1/nginx/conf/lua/limit_api_flow.lua:1>, client: 122.96.43.103, server: api.yoho.cn, request: "GET /?udid=3fdfe1237c2186ac4431b314f6d47cc9&method=resources.simple.pice&udid=3fdfe1237c2186ac4431b314f6d47cc9&method=resources.simple.pice HTTP/1.1", host: "api.yoho.cn"
2019/03/21 15:09:30 [error] 19621#0: *406564387 lua entry thread aborted: runtime error: ...cal/openresty-1.9.15.1/nginx/conf/lua/limit_api_flow.lua:85: attempt to concatenate local 'req_uri_method' (a table value)
stack traceback:
... ... @@ -6,14 +6,35 @@ local cjson = require "cjson"
local default_err_code=9999991
local default_err_msg="系统正忙,请稍后重试!"
function get_req_param(req_param)
local method = ngx.var.request_method
if "GET" == method then
return ngx.req.get_uri_args()[req_param]
else
ngx.req.read_body()
return ngx.req.get_post_args()[req_param]
function get_req_param(req_param)
local ret = nil
local args = nil
local err = nil
local http_req_method = ngx.var.request_method
if "GET" == http_req_method then
args, err = ngx.req.get_uri_args()
elseif "POST" == http_req_method then
ngx.req.read_body()
args, err = ngx.req.get_post_args()
end
--- make sure this is some params
if not args then
ngx.say("failed to get args: ", err)
return nil
end
-- the value may be table, like: /test?foo=bar&bar=baz&bar=blah
for key, val in pairs(args) do
if key == req_param then
if type(val) == "table" then
ret = val[0] or val[1]
else
ret = val
end
end
end
return ret
end
function get_req_uri()
... ...