Class: RevisionPlate::Middleware

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

Constant Summary collapse

ACCEPT_METHODS =
%w[GET HEAD].freeze

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Middleware.



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

def initialize(app, path, file = nil, options={})
  @path = path
  @app = app
  @revision_app = App.new(file, **options)
end

Instance Method Details

#call(env) ⇒ Object



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

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