Class: Gluttonberg::Middleware::Honeypot

Inherits:
Object
  • Object
show all
Defined in:
lib/gluttonberg/middleware/honeypot.rb

Instance Method Summary (collapse)

Constructor Details

- (Honeypot) initialize(app, field_name)

A new instance of Honeypot



5
6
7
8
# File 'lib/gluttonberg/middleware/honeypot.rb', line 5

def initialize(app, field_name)
  @app = app
  @field_name = field_name
end

Instance Method Details

- (Object) call(env)



10
11
12
13
14
15
16
17
18
# File 'lib/gluttonberg/middleware/honeypot.rb', line 10

def call(env)
  form_hash = env["rack.request.form_hash"]

  if form_hash && form_hash[@field_name] =~ /\S/
    [200, {'Content-Type' => 'text/html', "Content-Length" => "0"}, []]
  else
    @app.call(env)
  end
end