-
-
Save leandromoreira/25a559cc1b3ac24eb9bd29df4e8cae64 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http { | |
server { | |
listen 8080; | |
location /lua_content { | |
default_type 'text/plain'; | |
content_by_lua_block { | |
local redis_client = redis_cluster:new(config) | |
local rate, err = redis_rate.measure(redis_client, ngx.var.arg_token) | |
if err then | |
ngx.log(ngx.ERR, "err: ", err) | |
ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR) | |
end | |
if rate > 10 then | |
ngx.exit(ngx.HTTP_FORBIDDEN) | |
end | |
ngx.say(rate) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment