require 'rack/utils'
module Locomotive
module Hosting
module Bushido
class Middleware
# BUSHIDO_JS_URL = 'http://localhost:4567/javascripts/bushido.js'
BUSHIDO_JS_URL = 'http://bushi.do/api/bushido.js'
include Rack::Utils
def initialize(app, opts = {})
@app = app
@bushido_app_name = ENV['BUSHIDO_APP']
@bushido_metrics_token = ENV['BUSHIDO_METRICS_TOKEN']
@bushido_claimed = ::Locomotive.bushido_app_claimed?
end
def call(env)
status, headers, response = @app.call(env)
content = ""
response.each { |part| content += part }
# "claiming" bar + stats ?
content.gsub!(/<\/body>/i, <<-STR