mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-03 03:40:49 +08:00
接口请求限流
This commit is contained in:
@@ -1172,7 +1172,7 @@ class ApplicationController < ActionController::Base
|
||||
else
|
||||
record_count = 1
|
||||
end
|
||||
tip_exception("非法请求") if record_count > 100
|
||||
normal_status("请求太快,请稍后再试。") if record_count > 100
|
||||
|
||||
Rails.cache.write("request/#{controller_name}/#{Time.now.strftime('%Y%m%d%H%M')}/#{request.remote_ip}", record_count, expires_in: 1.minute)
|
||||
rescue
|
||||
|
||||
Reference in New Issue
Block a user