Sha256: e9e63aa2cc7a930426ef8d6e6a92043de0824e1d9a4df09821d02e1ea8dbc763
Contents?: true
Size: 744 Bytes
Versions: 4
Compression:
Stored size: 744 Bytes
Contents
module Pushify class Rack def initialize(app) @app = app end def call(env) path = env["REQUEST_URI"] if (Pushify::Rails::Assets.includes?(path)) Pushify::Rails::Assets.response(path) else status, headers, response = @app.call(env) is_html = !response.is_a?(Array) && (headers["Content-Type"].nil? || headers["Content-Type"].include?("text/html")) if (is_html && response.body.match(/<\/body>/)) pushify_src = Pushify.javascript_src response.body = response.body.gsub(/(<\/body>)/, "#{pushify_src}</body>") headers["Content-Length"] = (response.body.size).to_s end [status, headers, response] end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
pushify-1.2.2 | lib/pushify/rack.rb |
pushify-1.2.1 | lib/pushify/rack.rb |
pushify-1.2.0 | lib/pushify/rack.rb |
pushify-1.1.0 | lib/pushify/rack.rb |