def call(env)
return @app.call(env) unless Bullet.enable?
Bullet.start_request
status, headers, response = @app.call(env)
response_body = nil
if Bullet.notification?
if !file?(headers) && !sse?(headers) && !empty?(response) &&
status == 200 && html_request?(headers, response)
response_body = response_body(response)
response_body = append_to_html_body(response_body, footer_note) if Bullet.add_footer
response_body = append_to_html_body(response_body, Bullet.gather_inline_notifications)
headers['Content-Length'] = response_body.bytesize.to_s
end
Bullet.perform_out_of_channel_notifications(env)
end
[status, headers, response_body ? [response_body] : response]
ensure
Bullet.end_request
end