...
|
...
|
@@ -27,6 +27,7 @@ function limit(limit_key,max_limit,seconds) |
|
|
|
|
|
if limit then
|
|
|
if tonumber(limit)>max_limit then
|
|
|
ngx.log(ngx.ERR,"[REQUEST LIMITED] " , string.format("Method: %s, currentQPS:%d, maxQPS: %d", req_uri_method, limit, max_limit))
|
|
|
return false
|
|
|
else
|
|
|
return true
|
...
|
...
|
@@ -74,7 +75,6 @@ function rate_limit() |
|
|
-- do limit
|
|
|
local flag= limit("yh:nginx:limitflow:" .. req_uri_method, max_per_sencond)
|
|
|
if not flag then
|
|
|
ngx.log(ngx.ERR,"The request is limited :" .. req_uri_method)
|
|
|
ngx.header["Content-Type"]="application/json;charset=utf-8"
|
|
|
local msg='{"code":' .. err_code .. ',"message":"'.. err_msg .. '"}'
|
|
|
ngx.say(msg)
|
...
|
...
|
|