Class: Partiarelic::Middleware

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

Constant Summary collapse

ACCEPT_METHODS =
%w[GET HEAD].freeze

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Middleware

Returns a new instance of Middleware.



5
6
7
8
9
# File 'lib/partiarelic/middleware.rb', line 5

def initialize(app, options={})
  @app = app
  @options = options
  @partiarelic_app = App.new(options)
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/partiarelic/middleware.rb', line 13

def call(env)
  if env['PATH_INFO'] == @options[:path] && ACCEPT_METHODS.include?(env['REQUEST_METHOD'])
    @partiarelic_app.call(env)
  else
    @app.call(env)
  end
end