Class: Lecter::Rack
- Inherits:
-
Object
- Object
- Lecter::Rack
- Defined in:
- lib/lecter/rack.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Rack
constructor
A new instance of Rack.
Constructor Details
#initialize(app) ⇒ Rack
Returns a new instance of Rack.
5 6 7 8 |
# File 'lib/lecter/rack.rb', line 5 def initialize(app) @app = app @tp = Lecter::TracePoint.new.build end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/lecter/rack.rb', line 10 def call(env) if ::Rack::Request.new(env).params['lecter_enabled'] thread = Thread.current thread[:items] = '' tp.enable ActionController::Base.allow_forgery_protection = false end status, headers, response = @app.call(env) if tp.enabled? response = [status.to_s + thread[:items]] status = 200 headers = {} end [status, headers, response] ensure if tp.enabled? tp.disable ActionController::Base.allow_forgery_protection = true Thread.current[:items] = nil end end |