class Instrumentation::RackApp

Main Rack application that serves the `websocket` data or the index page

Public Class Methods

new(report) click to toggle source
# File lib/instrumentation/rack_app.rb, line 6
def initialize(report)
  @report = report
  @view   = Instrumentation::View.new
end

Public Instance Methods

call(env) click to toggle source
# File lib/instrumentation/rack_app.rb, line 11
def call(env)
  if env['HTTP_UPGRADE'] == 'websocket'
    socket = Tubesock.hijack(env)
    socket.listen
    @report.socket = socket
    [-1, {}, []]
  else
    ['200', { 'Content-Type' => 'text/html' }, [@view.render]]
  end
end