Skip to content

Instantly share code, notes, and snippets.

@leandromoreira
Last active January 26, 2019 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leandromoreira/25a559cc1b3ac24eb9bd29df4e8cae64 to your computer and use it in GitHub Desktop.
Save leandromoreira/25a559cc1b3ac24eb9bd29df4e8cae64 to your computer and use it in GitHub Desktop.
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