Skip to content

Commit

Permalink
Add ability to use multiple instances of middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
fatkodima committed Oct 17, 2019
1 parent 6731e23 commit 5cd776a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/rack/attack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,15 @@ def clear!

attr_reader :configuration

def initialize(app)
def initialize(app, &block)
@app = app
@configuration = self.class.configuration
@configuration =
if block_given?
configuration = Configuration.new
configuration.instance_exec(&block)
else
self.class.configuration
end
end

def call(env)
Expand Down

0 comments on commit 5cd776a

Please sign in to comment.