Sha256: 35ad1543ec4c7023efbcddb19692eb26b0525789aae578fba2712c7f04cd8703
Contents?: true
Size: 616 Bytes
Versions: 8
Compression:
Stored size: 616 Bytes
Contents
module CacheableFlash class Middleware def initialize app @app = app end def call env status, headers, body = @app.call env return [status, headers, body] unless headers["Content-Type"].try(:include?, "text/html") new_body = "" body.each { |part| new_body << part } process! new_body headers.delete("Content-Length") [status, headers, [new_body]] end private def process! body body.gsub!("</head>", "<script>#{javascript}</script></head>") end def javascript File.read(__dir__ + "/javascript.js") end end end
Version data entries
8 entries across 8 versions & 1 rubygems