Class: Instrumentation::RackApp

Inherits:
Object
  • Object
show all
Defined in:
lib/instrumentation/rack_app.rb

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(report) ⇒ RackApp

Returns a new instance of RackApp.



6
7
8
9
# File 'lib/instrumentation/rack_app.rb', line 6

def initialize(report)
  @report = report
  @view   = Instrumentation::View.new
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# 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