• Like
  • Save
Rack Middleware
Upcoming SlideShare
Loading in...5
×

Rack Middleware

  • 7,250 views
Uploaded on

These slides are taken from my talk titled "In a World of Middleware, Who Needs Monolithic Applications?" presented at MountainWest Ruby Conf 2009, held March 13-14 in Salt Lake City, UT.

These slides are taken from my talk titled "In a World of Middleware, Who Needs Monolithic Applications?" presented at MountainWest Ruby Conf 2009, held March 13-14 in Salt Lake City, UT.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
  • Should be downloadable.

    :-(
    Are you sure you want to
    Your message goes here
  • rack
    Are you sure you want to
    Your message goes here
  • Disabled download? Lame.
    Are you sure you want to
    Your message goes here
No Downloads

Views

Total Views
7,250
On Slideshare
0
From Embeds
0
Number of Embeds
6

Actions

Shares
Downloads
17
Comments
3
Likes
22

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide















































































































































































Transcript

  • 1. Rack Middleware Tuesday, March 17, 2009
  • 2. m/ Tuesday, March 17, 2009
  • 3. NEED Tuesday, March 17, 2009
  • 4. CHOICE 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
  • 8. 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
  • 10. Free during HackFest Tuesday, March 17, 2009
  • 11. Discount for Sign Up Tuesday, March 17, 2009
  • 12. CGI Tuesday, March 17, 2009
  • 13. app.cgi Tuesday, March 17, 2009
  • 14. WARNING Tuesday, March 17, 2009
  • 15. Contains Perl Tuesday, March 17, 2009
  • 16. old skool perl cgi 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
  • 23. Monolith Tuesday, March 17, 2009
  • 24. :-( Tuesday, March 17, 2009
  • 25. Rails Tuesday, March 17, 2009
  • 26. Merb Sinatra Mack Ramaze Waves Tuesday, March 17, 2009
  • 27. Authentication Tuesday, March 17, 2009
  • 28. Single Sign-On Tuesday, March 17, 2009
  • 29. Caching Tuesday, March 17, 2009
  • 30. Authentication Example: OpenID + OAuth Tuesday, March 17, 2009
  • 31. Install Auth Plugin(s) Tuesday, March 17, 2009
  • 32. Install Auth Plugin(s) Generate Controllers Tuesday, March 17, 2009
  • 33. Install Auth Plugin(s) Generate Controllers Generate Models Tuesday, March 17, 2009
  • 34. Install Auth Plugin(s) Generate Controllers Generate Models Generate Migrations 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
  • 37. :-( Tuesday, March 17, 2009
  • 38. The Web Tuesday, March 17, 2009
  • 39. Tuesday, March 17, 2009
  • 40. HTTP Tuesday, March 17, 2009
  • 41. Intermediaries HTTP Tuesday, March 17, 2009
  • 42. Intermediaries App HTTP Tuesday, March 17, 2009
  • 43. Intermediaries App HTTP Tuesday, March 17, 2009
  • 44. Rack Tuesday, March 17, 2009
  • 45. Tuesday, March 17, 2009
  • 46. HTTP Tuesday, March 17, 2009
  • 47. Intermediaries HTTP Tuesday, March 17, 2009
  • 48. Middleware HTTP Tuesday, March 17, 2009
  • 49. Middleware App HTTP Tuesday, March 17, 2009
  • 50. Rack is the Web Tuesday, March 17, 2009
  • 51. The Web is Rack Tuesday, March 17, 2009
  • 52. WSGI Tuesday, March 17, 2009
  • 53. SPEC 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
  • 62. config.ru Tuesday, March 17, 2009
  • 63. $ rackup config.ru Tuesday, March 17, 2009
  • 64. $ curl http://localhost:9292 Tuesday, March 17, 2009
  • 65. Hello Tuesday, March 17, 2009
  • 66. class App def call(env) [200, {...}, [...]] end end Tuesday, March 17, 2009
  • 67. SPEC Tuesday, March 17, 2009
  • 68. $ rake SPEC Tuesday, March 17, 2009
  • 69. Rack::Lint Tuesday, March 17, 2009
  • 70. lambda { |env| [ 200, { ‘Content-Type’ => ‘text/plain’, ‘Content-Length’ => ‘5’ }, [‘Hello’] ] } Tuesday, March 17, 2009
  • 71. env Tuesday, March 17, 2009
  • 72. REQUEST_METHOD Tuesday, March 17, 2009
  • 73. env[‘REQUEST_METHOD’] Tuesday, March 17, 2009
  • 74. GET PUT POST DELETE HEAD OPTIONS TRACE Tuesday, March 17, 2009
  • 75. PATH_INFO Tuesday, March 17, 2009
  • 76. /items/123 Tuesday, March 17, 2009
  • 77. HTTP_* Tuesday, March 17, 2009
  • 78. HTTP_ACCEPT Tuesday, March 17, 2009
  • 79. application/json Tuesday, March 17, 2009
  • 80. rack.* Tuesday, March 17, 2009
  • 81. rack.input (the input stream) Tuesday, March 17, 2009
  • 82. #gets #each #read #rewind Tuesday, March 17, 2009
  • 83. yournamespace.* Tuesday, March 17, 2009
  • 84. request = Rack::Request.new(env) Tuesday, March 17, 2009
  • 85. request.post? Tuesday, March 17, 2009
  • 86. request.params[‘id’] Tuesday, March 17, 2009
  • 87. request[‘HTTP_IF_MATCH’] Tuesday, March 17, 2009
  • 88. m/ Tuesday, March 17, 2009
  • 89. Middleware App HTTP 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
  • 97. Rack::Profiler Tuesday, March 17, 2009
  • 98. Rack::MailExceptions Tuesday, March 17, 2009
  • 99. Rack::JSONP Tuesday, March 17, 2009
  • 100. Rack::CSSHTTPRequest Tuesday, March 17, 2009
  • 101. Rack::Cache http://github.com/rtomayko/rack-cache Tuesday, March 17, 2009
  • 102. Rack::NotFound Tuesday, March 17, 2009
  • 103. 404 Tuesday, March 17, 2009
  • 104. Middleware App HTTP 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
  • 110. Middleware App HTTP Tuesday, March 17, 2009
  • 111. Middleware App HTTP Tuesday, March 17, 2009
  • 112. Cooperative Middleware Tuesday, March 17, 2009
  • 113. URI Space Tuesday, March 17, 2009
  • 114. /* Tuesday, March 17, 2009
  • 115. /just-what-it-needs Tuesday, March 17, 2009
  • 116. CloudKit Tuesday, March 17, 2009
  • 117. Open Web JSON Appliance Tuesday, March 17, 2009
  • 118. expose :notes, :todos Tuesday, March 17, 2009
  • 119. expose :notes, :todos Tuesday, March 17, 2009
  • 120. contain :notes, :todos 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
  • 122. CloudKit::OAuthFilter /oauth/* Tuesday, March 17, 2009
  • 123. CloudKit::OpenIDFilter /login /logout /openid_complete Tuesday, March 17, 2009
  • 124. CloudKit::Service /notes/* /todos/* Tuesday, March 17, 2009
  • 125. ? 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
  • 134. Service or Desktop App OAuth OpenID Service Tuesday, March 17, 2009
  • 135. Service or Desktop App OAuth OpenID Service Tuesday, March 17, 2009
  • 136. Service or Desktop App {...} OAuth OpenID Service Tuesday, March 17, 2009
  • 137. Service or Desktop App OAuth OpenID Service Tuesday, March 17, 2009
  • 138. Service or Desktop App OAuth OpenID Service {...} Login Tuesday, March 17, 2009
  • 139. Service or Desktop App OAuth OpenID Service Tuesday, March 17, 2009
  • 140. Service or Desktop App OAuth OpenID Service Tuesday, March 17, 2009
  • 141. Service or Desktop App OAuth OpenID Service Tuesday, March 17, 2009
  • 142. Service or Desktop App OAuth OpenID Service Tuesday, March 17, 2009
  • 143. Announcing Middleware Presence Tuesday, March 17, 2009
  • 144. HTTP Via Tuesday, March 17, 2009
  • 145. Via: 1.0 ricky, 1.1 ethel, 1.1 fred Tuesday, March 17, 2009
  • 146. Via: 1.0 ricky, 1.1 ethel, 1.1 fred Tuesday, March 17, 2009
  • 147. Via: 1.0 ricky, 1.1 ethel, 1.1 fred Tuesday, March 17, 2009
  • 148. Via: 1.0 ricky, 1.1 ethel, 1.1 fred Tuesday, March 17, 2009
  • 149. env[‘cloudkit.auth’] = 1 Tuesday, March 17, 2009
  • 150. env[‘cloudkit.via’] << ‘cloudkit.filter.oauth’ Tuesday, March 17, 2009
  • 151. env[‘cloudkit.via’] << ‘cloudkit.filter.openid’ Tuesday, March 17, 2009
  • 152. env[‘cloudkit.user’] = ‘http://joncrosby.me’ Tuesday, March 17, 2009
  • 153. Alternative Stacks Tuesday, March 17, 2009
  • 154. Rack::Map Tuesday, March 17, 2009
  • 155. map “/” do run Blog::Public end map “/db” do run Blog::DBAdmin end Tuesday, March 17, 2009
  • 156. Rack::Map + Sinatra 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
  • 160. require ‘sinatra’ for “apps” /* URI space Tuesday, March 17, 2009
  • 161. require ‘sinatra/base’ MyClass < Sinatra::Base Minimal Sinatra (routing, rendering, etc.) Tuesday, March 17, 2009
  • 162. m/ Tuesday, March 17, 2009
  • 163. use MySinatraApp run SomeOtherApp Tuesday, March 17, 2009
  • 164. Rack::Cascade Tuesday, March 17, 2009
  • 165. app1 = lambda { ... } app2 = lambda { ... } run Rack::Cascade.new([app1, app2]) Tuesday, March 17, 2009
  • 166. Sinatra as Middleware in Rails 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
  • 168. CloudKit in Rails Tuesday, March 17, 2009
  • 169. Rails::Initializer.run do |config| config.use.middleware ‘CloudKit::Service’, :collections => [:notes, :todos] end Tuesday, March 17, 2009
  • 170. Middleware App HTTP 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
  • 174. New Unit of Composition Tuesday, March 17, 2009
  • 175. m/ Tuesday, March 17, 2009