Rack
     Shaokun Wu
shaokun@kudelabs.com
•       web framework

•   frameworkless   web application
•          web servers
    WEBrick, Mongrel, Thin, Passenger...

•                               web server handlers
???

•n   frameworks

•m   web servers

•          web server handlers
n*m
n * m => n + m
HTTP
Request => Response
Request

• GET / HTTP/1.1
  User-Agent: curl/7.12.2 ...
  Host: ruby-lang.org
  Pragma: no-cache Accept: */*
Response
•   HTTP/1.1 302 Found
•   Date: Sat, 27 Oct 2007 10:07:53 GMT
    Server: Apache/2.0.54 (Debian GNU/Linux) mod_s...
Response


• Status Code
         to_i

• Headers
         each        yields key-value pairs

• Body
         each yields...
[status, headers, body]
Rack


•
•   HTTP     Ruby API
Hello Rack!

•   lambda { |env|
      [200,                           # Status Code
      {"Content-Type"=>"text/plain"}, ...
Rack Handlers
•   CGI
•   EventedMongrel
•   FastCGI
•   LSWS
•   Mongrel
•   SCGI
•   SwiftipliedMongrel
•   Thin
•   WEB...
•   Rack::Cascade
•   Rack::CommonLogger
•   Rack::Lint
•   Rack::Recursive
•   Rack::Reloader
•   Rack::ShowException
•  ...
Let’s code!
Hello Rack!
Response Timer
.NET or J2EE
in one second
No IE 6 Please!!!!!!!!!!
Thanks!
shaokun@kudelabs.com
Upcoming SlideShare
Loading in …5
×

Rack

1,472 views
1,413 views

Published on

广州 ruby 爱好者聚会上五分钟 topic

http://github.com/shaokun/rack-demo

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,472
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
15
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide





















  • Rack

    1. 1. Rack Shaokun Wu shaokun@kudelabs.com
    2. 2. • web framework • frameworkless web application
    3. 3. • web servers WEBrick, Mongrel, Thin, Passenger... • web server handlers
    4. 4. ??? •n frameworks •m web servers • web server handlers
    5. 5. n*m
    6. 6. n * m => n + m
    7. 7. HTTP Request => Response
    8. 8. Request • GET / HTTP/1.1 User-Agent: curl/7.12.2 ... Host: ruby-lang.org Pragma: no-cache Accept: */*
    9. 9. Response • HTTP/1.1 302 Found • Date: Sat, 27 Oct 2007 10:07:53 GMT Server: Apache/2.0.54 (Debian GNU/Linux) mod_ssl/2.0.54 OpenSSL/0.9.7e Location: http://www.ruby-lang.org/ Content-Length: 209 Content-Type: text/html; charset=iso-8859-1 • <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>302 Found</title> </head><body> <h1>Found</h1> <p>The document has moved <a href="http://www.ruby-lang.org/">here</ a>.</p> </body></html>
    10. 10. Response • Status Code to_i • Headers each yields key-value pairs • Body each yields strings
    11. 11. [status, headers, body]
    12. 12. Rack • • HTTP Ruby API
    13. 13. Hello Rack! • lambda { |env| [200, # Status Code {"Content-Type"=>"text/plain"}, # Headers ["Hello, world!"]] # Body }
    14. 14. Rack Handlers • CGI • EventedMongrel • FastCGI • LSWS • Mongrel • SCGI • SwiftipliedMongrel • Thin • WEBrick
    15. 15. • Rack::Cascade • Rack::CommonLogger • Rack::Lint • Rack::Recursive • Rack::Reloader • Rack::ShowException • Rack::ShowStatus • Rack::Static • Rack::URLMap • http://coderack.org/middlewares
    16. 16. Let’s code!
    17. 17. Hello Rack!
    18. 18. Response Timer
    19. 19. .NET or J2EE in one second
    20. 20. No IE 6 Please!!!!!!!!!!
    21. 21. Thanks! shaokun@kudelabs.com

    ×