- Life of a request
- Browser creates request
- Sends it to webserver (Unicorn)
- Sends it to Rails
- Sends it to spaghetti code
- HTML is returned
- Rack's job is to communicate between webservers and frameworks
- Only requirements of Rack app:
- A class that responds to
call, then returns[http_code, headers, body]@app.call(env)
- config.ru
require 'app'; run App.new
- A class that responds to
- Then call
rackupon CLI - PRY
- You can
cdinto objects lslists all the methods
- You can
- Experimenting with #call
Rails::Application#callis the entry pointshow-method callshows source code- Parameter in
callis{"REQUEST_METHOD" => "GET", "PATH_INFO" => '/', "RACK.INPUT" => ""} response[0] # => 200response[1] # => Hash of headers, like 'Content-Length'response[2] # => Array of body
- Web Request from browser to webserver
thin start- This calls
Thin::Server.start('0.0.0', 3000, app) - It can make TcpServers (among other servers, like UnixServer)
- EventMachine is used to start the server
- Thin parses request into something Rack can use
- Zed Shaw wrote the Mongrel parser C extension
- This calls
- Unicorn and Puma
- Doesn't use EventMachine, instead it uses
kgio(kinda complicated) - Eventually calls
@app.call(env)
- Doesn't use EventMachine, instead it uses
- David rolls his own webserver. Cool stuff.
- Actually not as scary as I thought
- Don't try this at home, but play around and be curious
- David's Code on github
Created
April 30, 2013 21:33
-
-
Save jamesgary/5492121 to your computer and use it in GitHub Desktop.
From Rails to the web server to client to browser - David Padilla (@dabit) - RailsConf 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment