controllers: refactor rate limits.
Refactor controllers so that endpoint rate limits are declared locally, with the endpoint, instead of globally, in a single method in ApplicationController. This way an endpoint's rate limit is declared in the same file as the endpoint itself. This is so we can add fine-grained rate limits for certain GET requests. Before rate limits were only for non-GET requests.
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
class CommentVotesController < ApplicationController
|
||||
respond_to :js, :json, :xml, :html
|
||||
|
||||
rate_limit :create, rate: 1.0/1.second, burst: 200
|
||||
rate_limit :destroy, rate: 1.0/1.second, burst: 200
|
||||
|
||||
def index
|
||||
@comment_votes = authorize CommentVote.visible(CurrentUser.user).paginated_search(params, count_pages: true)
|
||||
@comment_votes = @comment_votes.includes(:user, comment: [:creator, { post: [:uploader, :media_asset] }]) if request.format.html?
|
||||
|
||||
Reference in New Issue
Block a user