Skip to content
Browse files

Add async_sinatra integration example

  • Loading branch information...
1 parent 303baf7 commit 684162712bcb79e15511d41cb91553d048d7516f @lifo committed
Showing with 50 additions and 0 deletions.
  1. +1 −0 Gemfile
  2. +8 −0 Gemfile.lock
  3. +41 −0 examples/sinatra_async.ru
View
1 Gemfile
@@ -23,6 +23,7 @@ group :example do
gem 'erubis'
gem 'async-rack'
+ gem 'async_sinatra'
platforms :mri_19 do
gem 'rainbows'
View
8 Gemfile.lock
@@ -26,6 +26,9 @@ GEM
arel (2.0.10)
async-rack (0.5.1)
rack (~> 1.1)
+ async_sinatra (0.5.0)
+ rack (>= 1.2.1)
+ sinatra (>= 1.0)
builder (2.1.2)
columnize (0.3.4)
daemons (1.1.4)
@@ -62,11 +65,15 @@ GEM
ruby-debug-base19 (>= 0.11.19)
ruby_core_source (0.1.5)
archive-tar-minitar (>= 0.5.2)
+ sinatra (1.2.6)
+ rack (~> 1.1)
+ tilt (>= 1.2.2, < 2.0)
thin (1.2.11)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
thor (0.14.6)
+ tilt (1.3.2)
turn (0.8.2)
ansi (>= 1.2.2)
tzinfo (0.3.29)
@@ -84,6 +91,7 @@ PLATFORMS
DEPENDENCIES
activerecord (~> 3.0.9)
async-rack
+ async_sinatra
cramp!
em-http-request
em-synchrony
View
41 examples/sinatra_async.ru
@@ -0,0 +1,41 @@
+require "rubygems"
+require "bundler"
+Bundler.setup(:default, :example)
+
+require 'cramp'
+require 'http_router'
+require 'sinatra/async'
+
+class Stream < Cramp::Action
+ def start
+ render "Hello!"
+ finish
+ end
+end
+
+class Home < Sinatra::Base
+ register Sinatra::Async
+ enable :inline_templates
+
+ aget '/' do
+ body <<-BODY
+ <html>
+ <head>
+ <title>Cramp meets Sinatra</title>
+ </head>
+
+ <body>
+ <a href='/cramp'>Say hi to Cramp</a>
+ </body>
+ </html>
+ BODY
+ end
+end
+
+routes = HttpRouter.new do
+ add('/cramp').to(Stream)
+end
+
+# bundle exec thin -V -R examples/sinatra_async.ru start
+# bundle exec rainbows -E deployment -c examples/rainbows.conf examples/sinatra_async.ru
+run Rack::Cascade.new([routes, Home])

0 comments on commit 6841627

Please sign in to comment.
Something went wrong with that request. Please try again.