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.
19 lines
572 B
Ruby
19 lines
572 B
Ruby
class PostDisapprovalsController < ApplicationController
|
|
respond_to :js, :html, :json, :xml
|
|
|
|
rate_limit :destroy, rate: 1.0/1.second, burst: 200
|
|
|
|
def create
|
|
@post_disapproval = authorize PostDisapproval.new(user: CurrentUser.user, **permitted_attributes(PostDisapproval))
|
|
@post_disapproval.save
|
|
respond_with(@post_disapproval)
|
|
end
|
|
|
|
def index
|
|
@post_disapprovals = authorize PostDisapproval.paginated_search(params)
|
|
@post_disapprovals = @post_disapprovals.includes(:user) if request.format.html?
|
|
|
|
respond_with(@post_disapprovals)
|
|
end
|
|
end
|