What is ‘Rack’ in Ruby/Rails?
Lets start with a basic browser-server interaction. Say you’re developing an app with Rails (or any other Ruby web framework) and it has a page located at ‘http://localhost:3000/users’ that displays all users. The ‘/users’ request is going to go to your Rails server asking to show all users.
Behind the scenes, this HTTP request that the browser sends looks like this:
// Request by the browser GET /users HTTP/1.1 Host: localhost Connection: close
And, the response sent by the server looks like:
// Response by the server HTTP/1.1 200 OK Content-Length: 25 Content-Type: text/html <html> ... </html>
Now, say you’re a web server. You have this Rails app loaded in you. And some browser came to you with that request having path ‘/users’. As a server you understand this HTTP request. But you don’t know what to do with it. You have to give it to your Rails app, because it knows very well...
Continue reading →