Permalink
Browse files

Sinatra and Rack

  • Loading branch information...
1 parent b30d680 commit 8c5613730407121ca97978df44ad515b4596da93 @jcarlosgarcia committed Mar 3, 2012
Showing with 22 additions and 0 deletions.
  1. +16 −0 rack_sinatra/my_middleware.rb
  2. +6 −0 rack_sinatra/my_sinatra.rb
@@ -0,0 +1,16 @@
+module MyMiddleware
+ class Hello
+ def initialize(app)
+ @app = app
+ end
+
+ def call(env)
+ if env['PATH_INFO'] == '/hello'
+ [200, {"Content-Type" => "text/plain"}, ["Hello from the middleware!"]]
+ else
+ # forward the request
+ @app.call(env)
+ end
+ end
+ end
+end
@@ -0,0 +1,6 @@
+require 'sinatra'
+require './my_middleware'
+use MyMiddleware::Hello
+get '/' do
+ "Hello Ruby participants from across the globe!"
+end

0 comments on commit 8c56137

Please sign in to comment.