More Related Content Similar to Rack Middleware (20) Rack Middleware1. Rack
Middleware
Tuesday, March 17, 2009
5. Jon Crosby
http://joncrosby.me
Tuesday, March 17, 2009
6. CloudKit
http://getcloudkit.com
Tuesday, March 17, 2009
7. rack-contrib
http://github.com/rack/rack-contrib
Tuesday, March 17, 2009
9. Engine Yard Solo
“The platform for
on-demand management of your
Ruby on Rails application
in the cloud.”
Tuesday, March 17, 2009
17. if ($cgi->param(‘action’) eq ‘all’) {
my $sql = “select * from customer”;
my $rows =
$dbh->selectall_arrayref($sql);
if (@$rows) {
print “<table border=1>” .
“<th>name</th>” .
...
Tuesday, March 17, 2009
18. if ($cgi->param(‘action’) eq ‘all’) {
my $sql = “select * from customer”;
my $rows =
$dbh->selectall_arrayref($sql);
if (@$rows) {
print “<table border=1>” .
“<th>name</th>” .
...
Tuesday, March 17, 2009
19. if ($cgi->param(‘action’) eq ‘all’) {
my $sql = “select * from customer”;
my $rows =
$dbh->selectall_arrayref($sql);
if (@$rows) {
print “<table border=1>” .
“<th>name</th>” .
...
Tuesday, March 17, 2009
20. if ($cgi->param(‘action’) eq ‘all’) {
my $sql = “select * from customer”;
my $rows =
$dbh->selectall_arrayref($sql);
if (@$rows) {
print “<table border=1>” .
“<th>name</th>” .
...
Tuesday, March 17, 2009
21. if ($cgi->param(‘action’) eq ‘all’) {
my $sql = “select * from customer”;
my $rows =
$dbh->selectall_arrayref($sql);
if (@$rows) {
print “<table border=1>” .
“<th>name</th>” .
...
Tuesday, March 17, 2009
22. if ($cgi->param(‘action’) eq ‘all’) {
my $sql = “select * from customer”;
my $rows =
$dbh->selectall_arrayref($sql);
if (@$rows) {
print “<table border=1>” .
“<th>name</th>” .
...
Tuesday, March 17, 2009
26. Merb
Sinatra
Mack
Ramaze
Waves
Tuesday, March 17, 2009
35. Install Auth Plugin(s)
Generate Controllers
Generate Models
Generate Migrations
Modify Existing Controllers
Tuesday, March 17, 2009
36. Install Auth Plugin(s)
Generate Controllers
Generate Models
Generate Migrations
Modify Existing Controllers
Monkey Patch Rails
Tuesday, March 17, 2009
54. lambda { |env|
[
200,
{
‘Content-Type’ => ‘text/plain’,
‘Content-Length’ => ‘5’
},
[‘Hello’]
]
}
Tuesday, March 17, 2009
55. lambda { |env|
[
200,
{
‘Content-Type’ => ‘text/plain’,
‘Content-Length’ => ‘5’
},
[‘Hello’]
]
}
Tuesday, March 17, 2009
56. lambda { |env|
[
200,
{
‘Content-Type’ => ‘text/plain’,
‘Content-Length’ => ‘5’
},
[‘Hello’]
]
}
Tuesday, March 17, 2009
57. lambda { |env|
[
200,
{
‘Content-Type’ => ‘text/plain’,
‘Content-Length’ => ‘5’
},
[‘Hello’]
]
}
Tuesday, March 17, 2009
58. lambda { |env|
[
200,
{
‘Content-Type’ => ‘text/plain’,
‘Content-Length’ => ‘5’
},
[‘Hello’]
]
}
Tuesday, March 17, 2009
59. lambda { |env|
[
200,
{
‘Content-Type’ => ‘text/plain’,
‘Content-Length’ => ‘5’
},
[‘Hello’]
]
}
Tuesday, March 17, 2009
60. lambda { |env|
[
200,
{
‘Content-Type’ => ‘text/plain’,
‘Content-Length’ => ‘5’
},
[‘Hello’]
]
}
Tuesday, March 17, 2009
61. run lambda { |env|
[
200,
{
‘Content-Type’ => ‘text/plain’,
‘Content-Length’ => ‘5’
},
[‘Hello’]
]
}
Tuesday, March 17, 2009
66. class App
def call(env)
[200, {...}, [...]]
end
end
Tuesday, March 17, 2009
70. lambda { |env|
[
200,
{
‘Content-Type’ => ‘text/plain’,
‘Content-Length’ => ‘5’
},
[‘Hello’]
]
}
Tuesday, March 17, 2009
74. GET
PUT
POST
DELETE
HEAD
OPTIONS
TRACE
Tuesday, March 17, 2009
81. rack.input
(the input stream)
Tuesday, March 17, 2009
82. #gets
#each
#read
#rewind
Tuesday, March 17, 2009
90. use MiddlewareA
use MiddlewareB
use MiddlewareC
run app
Tuesday, March 17, 2009
91. class GoSlower
def initialize(app)
@app = app
end
def call(env)
sleep(1)
@app.call(env)
end
end
Tuesday, March 17, 2009
92. class GoSlower
def initialize(app)
@app = app
end
def call(env)
sleep(1)
@app.call(env)
end
end
Tuesday, March 17, 2009
93. class GoSlower
def initialize(app)
@app = app
end
def call(env)
sleep(1)
@app.call(env)
end
end
Tuesday, March 17, 2009
94. class GoSlower
def initialize(app)
@app = app
end
def call(env)
sleep(1)
@app.call(env)
end
end
Tuesday, March 17, 2009
95. class GoSlower
def initialize(app)
@app = app
end
def call(env)
sleep(1)
@app.call(env)
end
end
Tuesday, March 17, 2009
96. rack-contrib
http://github.com/rack/rack-contrib
Tuesday, March 17, 2009
101. Rack::Cache
http://github.com/rtomayko/rack-cache
Tuesday, March 17, 2009
105. use MiddlewareA
use MiddlewareB
use MiddlewareC
run app
Tuesday, March 17, 2009
106. class App
def call(env)
[200, {...}, [...]]
end
end
Tuesday, March 17, 2009
107. class GoSlower
def initialize(app)
@app = app
end
def call(env)
sleep(1)
@app.call(env)
end
end
Tuesday, March 17, 2009
108. class GoSlower
def initialize(app)
@app = app
end
def call(env)
sleep(1)
@app.call(env)
end
end
Tuesday, March 17, 2009
109. use MiddlewareA
use MiddlewareB
use MiddlewareC
run app
Tuesday, March 17, 2009
117. Open Web
JSON
Appliance
Tuesday, March 17, 2009
121. use Rack::Pool::Session
use CloudKit::OAuthFilter
use CloudKit::OpenIDFilter
use CloudKit::Service, :collections => [:notes, :todos]
(run DefaultApp)
Tuesday, March 17, 2009
126. Browser
OAuth OpenID Service
Tuesday, March 17, 2009
127. Browser
OAuth OpenID Service
Tuesday, March 17, 2009
128. Browser
{...}
OAuth OpenID Service
Tuesday, March 17, 2009
129. Browser
OAuth OpenID Service
Tuesday, March 17, 2009
130. Browser
OAuth OpenID Service
{...}
Login
Tuesday, March 17, 2009
131. Browser
OAuth OpenID Service
Tuesday, March 17, 2009
132. Browser
OAuth OpenID Service
Tuesday, March 17, 2009
133. Browser
OAuth OpenID Service
Tuesday, March 17, 2009
143. Announcing
Middleware
Presence
Tuesday, March 17, 2009
144. HTTP
Via
Tuesday, March 17, 2009
155. map “/” do
run Blog::Public
end
map “/db” do
run Blog::DBAdmin
end
Tuesday, March 17, 2009
157. require ‘sinatra/base’
module Blog
class Public < Sinatra::Base
get ‘/’ do
erb :index
end
end
end
Tuesday, March 17, 2009
158. require ‘sinatra/base’
module Blog
class Public < Sinatra::Base
get ‘/’ do
erb :index
end
end
end
Tuesday, March 17, 2009
159. require ‘sinatra/base’
module Blog
class Public < Sinatra::Base
get ‘/’ do
erb :index
end
end
end
Tuesday, March 17, 2009
161. require ‘sinatra/base’
MyClass < Sinatra::Base
Minimal Sinatra (routing, rendering, etc.)
Tuesday, March 17, 2009
165. app1 = lambda { ... }
app2 = lambda { ... }
run Rack::Cascade.new([app1, app2])
Tuesday, March 17, 2009
167. class X < Sinatra::Base
get ‘/what’ do
‘what’
end
end
Rails::Initializer.run do |config|
config.use.middleware ‘X’
end
Tuesday, March 17, 2009
171. Middleware App
Rails
HTTP
Tuesday, March 17, 2009
172. Middleware App
Rails Merb
HTTP
Tuesday, March 17, 2009
173. Middleware App
Rails Merb *
HTTP
Tuesday, March 17, 2009