Class: Rack::Bounce
- Inherits:
-
Object
- Object
- Rack::Bounce
- Defined in:
- lib/rack/bounce.rb,
lib/rack/bounce/version.rb
Constant Summary collapse
- DEFAULT_BOUNCER =
lambda do |request| checks = [ lambda { |req| ; req.user_agent =~ /masscan/ } ] checks.any? do |check| check.call request end end
- VERSION =
"0.1.0"
Instance Method Summary collapse
- #bounce?(env) ⇒ Boolean
- #call(env) ⇒ Object
-
#initialize(app, &bouncer) ⇒ Bounce
constructor
A new instance of Bounce.
Constructor Details
#initialize(app, &bouncer) ⇒ Bounce
Returns a new instance of Bounce.
15 16 17 18 |
# File 'lib/rack/bounce.rb', line 15 def initialize(app, &bouncer) @app = app @bouncer = bouncer || DEFAULT_BOUNCER end |
Instance Method Details
#bounce?(env) ⇒ Boolean
28 29 30 31 |
# File 'lib/rack/bounce.rb', line 28 def bounce?(env) request = ::Rack::Request.new env @bouncer.call request end |
#call(env) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/rack/bounce.rb', line 20 def call(env) if bounce?(env) [403, { }, [ ]] else @app.call env end end |