[refs #374] Add rate limit
This commit is contained in:
parent
ff8f9da14f
commit
58d9a972ef
2
Gemfile
2
Gemfile
|
@ -53,6 +53,8 @@ gem 'jquery-rails', '~> 2.0.2'
|
|||
gem 'ruby-haml-js', '~> 0.0.3'
|
||||
gem 'rails-backbone', '~> 0.7.2'
|
||||
|
||||
gem 'rack-throttle'
|
||||
|
||||
group :assets do
|
||||
gem 'sass-rails', '~> 3.2.5'
|
||||
gem 'coffee-rails', '~> 3.2.2'
|
||||
|
|
|
@ -223,6 +223,8 @@ GEM
|
|||
rack
|
||||
rack-test (0.6.1)
|
||||
rack (>= 1.0)
|
||||
rack-throttle (0.3.0)
|
||||
rack (>= 1.0.0)
|
||||
rails (3.2.7)
|
||||
actionmailer (= 3.2.7)
|
||||
actionpack (= 3.2.7)
|
||||
|
@ -394,6 +396,7 @@ DEPENDENCIES
|
|||
paperclip (~> 3.1.4)
|
||||
perform_later (~> 1.3.0)
|
||||
pg (~> 0.14.0)
|
||||
rack-throttle
|
||||
rails (= 3.2.7)
|
||||
rails-backbone (~> 0.7.2)
|
||||
rails3-generators
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
require File.expand_path('../boot', __FILE__)
|
||||
|
||||
require 'rails/all'
|
||||
require 'rack/throttle'
|
||||
|
||||
# If you have a Gemfile, require the gems listed there, including any gems
|
||||
# you've limited to :test, :development, or :production.
|
||||
|
@ -14,7 +15,11 @@ end
|
|||
|
||||
module Rosa
|
||||
class Application < Rails::Application
|
||||
|
||||
# Rate limit
|
||||
config.middleware.use Rack::Throttle::Interval, :cache => Redis.new, :key_prefix => :throttle, :min => 3.0
|
||||
config.middleware.use Rack::Throttle::Hourly, :max => 100
|
||||
config.middleware.use Rack::Throttle::Daily, :max => 5000
|
||||
|
||||
config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
|
||||
config.autoload_paths += %W(#{config.root}/lib)
|
||||
|
||||
|
|
Loading…
Reference in New Issue