Skip to content
This repository has been archived by the owner on Dec 7, 2018. It is now read-only.
Nando Vieira edited this page Jul 12, 2014 · 4 revisions

NOTE: This feature is available in Reel 0.5.0+

Reel allows you to snoop on incoming HTTP(S) connections, seeing what data is sent/received in realtime. This is useful for debugging Reel's realtime features including HTTP pipelining and websockets.

To enable connection spying, pass the spy: true option when creating a Reel server. Here is an example (taken from spy_hello_world.rb):

#!/usr/bin/env ruby
# Run with: bundle exec examples/hello_world.rb

require 'rubygems'
require 'bundler/setup'
require 'reel'

addr, port = '127.0.0.1', 1234

puts "*** Starting server on http://#{addr}:#{port}"
Reel::Server::HTTP.run(addr, port, spy: true) do |connection|
  # For keep-alive support
  connection.each_request do |request|
    # Ordinarily we'd route the request here, e.g.
    # route request.url
    request.respond :ok, "hello, world!\n"
  end

  # Reel takes care of closing the connection for you
  # If you would like to hand the connection off to another thread or actor,
  # use, connection.detach and then manually call connection.close when done
end

Note this line specifically, and the spy: true option:

Reel::Server::HTTP.run(addr, port, spy: true) do |connection|

When spying is active, Reel will automatically log all server traffic to the console:

Reel Spy

Clone this wiki locally