Class: Spamster::Rack::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/spamster/rack/middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



4
5
6
# File 'lib/spamster/rack/middleware.rb', line 4

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/spamster/rack/middleware.rb', line 8

def call(env)
  params = {}
  params[:referrer]    = env['HTTP_REFERER'] if env['HTTP_REFERER']
  params[:user_agent]  = env['HTTP_USER_AGENT'] if env['HTTP_USER_AGENT']
  params[:user_ip]     = env['REMOTE_ADDR'] if env['REMOTE_ADDR']
  Spamster.request_params = params

  response = @app.call(env)

  Spamster.request_params = nil
  response
end