Class: Rack::SockJS::DebugRequest
- Inherits:
-
Object
- Object
- Rack::SockJS::DebugRequest
- Defined in:
- lib/rack/sockjs.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ DebugRequest
constructor
A new instance of DebugRequest.
Constructor Details
#initialize(app) ⇒ DebugRequest
Returns a new instance of DebugRequest.
55 56 57 |
# File 'lib/rack/sockjs.rb', line 55 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/rack/sockjs.rb', line 59 def call(env) request = ::SockJS::Request.new(env) headers = request.headers.select { |key, value| not %w{version host accept-encoding}.include?(key.to_s) } ::SockJS.puts "\n~ \e[31m#{request.http_method} \e[32m#{request.path_info.inspect}#{" " + headers.inspect unless headers.empty?} \e[0m(\e[34m#{@prefix} app\e[0m)" headers = headers.map { |key, value| "-H '#{key}: #{value}'" }.join(" ") ::SockJS.puts "\e[90mcurl -X #{request.http_method} http://localhost:8081#{request.path_info} #{headers}\e[0m" result = @app.call(env) ensure ::SockJS.debug "Rack response: " + result.inspect end |