Class: RevisionPlate::Middleware
- Inherits:
-
Object
- Object
- RevisionPlate::Middleware
- Defined in:
- lib/revision_plate/middleware.rb
Constant Summary collapse
- ACCEPT_METHODS =
%w[GET HEAD].freeze
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, path, file = nil, options = {}) ⇒ Middleware
constructor
A new instance of Middleware.
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, ={}) @path = path @app = app @revision_app = App.new(file, **) 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 |