Skip to content
This repository has been archived by the owner on Dec 7, 2018. It is now read-only.

Webmachine Adapter

Asmod4n edited this page Sep 15, 2013 · 2 revisions

The Ruby version of the Webmachine HTTP framework has native support for Reel along with end-to-end streaming. In addition, it's lightweight and fast, and will speak HTTP properly so you don't have to!

To use Reel with Webmachine, add the following to your Gemfile:

# master is needed for Reel 0.4.0 support
gem 'webmachine', git: 'git://github.com/seancribbs/webmachine-ruby.git'

Then use config.adapter = :Reel when configuring a Webmachine app, e.g:

MyApp = Webmachine::Application.new do |app|
  app.routes do
    add ['*'], MyHome
  end

  app.configure do |config|
    config.ip      = MYAPP_IP
    config.port    = MYAPP_PORT
    config.adapter = :Reel

    # Optional: handler for incoming websockets
    config.adapter_options[:websocket_handler] = proc do |websocket|
      # websocket is a Reel::WebSocket
      websocket << "hello, world"
    end
  end
end

MyApp.run
Clone this wiki locally