Sha256: 449dec1f2b5cff79743cf5408e91ee2ed340a2eecc9228674cc2090865cace85

Contents?: true

Size: 518 Bytes

Versions: 3

Compression:

Stored size: 518 Bytes

Contents

require 'tubesock'

module Instrumentation
  # Main Rack application that serves the `websocket` data or the index page
  class RackApp
    def initialize(report)
      @report = report
      @view   = Instrumentation::View.new
    end

    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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
process-instrumentation-0.1.3 lib/instrumentation/rack_app.rb
process-instrumentation-0.1.2 lib/instrumentation/rack_app.rb
process-instrumentation-0.1.1 lib/instrumentation/rack_app.rb