Class: Rack::Pagelime
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Pagelime
constructor
A new instance of Pagelime.
Constructor Details
Instance Method Details
#call(env) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rack/pagelime.rb', line 17 def call(env) status, headers, response = @app.call(env) ::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Headers: #{headers}" ::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Status: #{status}" ::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Response: #{response}" if status == 200 && headers["content-type"].include?("text/html") body_content = StringIO.new response.each{|part| body_content << part} req = Rack::Request.new(env) ::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Processing For Path: #{req.path}" ::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Processing Body (size:#{body_content.length})" body = ::Pagelime.process_page(body_content, req.path) headers['content-length'] = body.length.to_s return [status, headers, [body]] else ::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Not touching this request" return [status, headers, response] end end |