Class: ProjectHoneypot::Rack::Header
- Inherits:
-
Object
- Object
- ProjectHoneypot::Rack::Header
- Defined in:
- lib/project_honeypot/rack/header.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Header
constructor
A new instance of Header.
Constructor Details
#initialize(app, options = {}) ⇒ Header
Returns a new instance of Header.
3 4 5 6 7 8 |
# File 'lib/project_honeypot/rack/header.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 |
# File 'lib/project_honeypot/rack/header.rb', line 10 def call(env) request = ::Rack::Request.new(env) url = ProjectHoneypot.lookup(request.ip) env['PROJECT_HONEYPOT_SAFE'] = url.safe? @app.call(request.env) end |