Class: ProjectHoneypot::Rack::Forbidden
- Inherits:
-
Object
- Object
- ProjectHoneypot::Rack::Forbidden
- Defined in:
- lib/project_honeypot/rack/forbidden.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Forbidden
constructor
A new instance of Forbidden.
Constructor Details
#initialize(app, options = {}) ⇒ Forbidden
Returns a new instance of Forbidden.
3 4 5 6 7 8 |
# File 'lib/project_honeypot/rack/forbidden.rb', line 3 def initialize(app, ={}) @app = app raise ArgumentError, 'Must specify an API key' unless [:api_key] ProjectHoneypot.api_key = [:api_key] end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/project_honeypot/rack/forbidden.rb', line 10 def call(env) request = ::Rack::Request.new(env) url = ProjectHoneypot.lookup(request.ip) if url.safe? @app.call(request.env) else [403, {"Content-Type" => "text/html"}, ["Forbidden"]] end end |