Jack Sebben Profile picture
Oct 19 1 tweets 2 min read Read on X
DAY 433 OF #100DaysOfCode
Study ⏰ 1.5 Hours

Today I dove deeper into Rack, an application server that's used in software development using Ruby.

I'm still a little fuzzy about some aspects of it, but my understanding is that the main function of Rack is to provide an interface for a web server and Ruby web application to interact.

The implementation details and syntax are still something I'm figuring out.

So far, this is what I understand down👇

👉 Installing Rack

To use Rack, you first need to `gem install` to your project you want to use Rack with.

Then you `require`/import Rack into the web application you want to interface with the web server.

👉 Using Rack

Here's where things get slightly fuzzy for me...

To use Rack with a web application, you first need to define a class that will represent the web application, with an instance method of `call` that takes the `env` as an argument.

The `env` is a data structure produced by Rack that represents and HTTP response passed on from the web server. The `env` is a Hash object that contains key-values that are associated with the different headers of the HTTP response.

The only thing necessary for the `call` instance method is that it must return an Array with these 3 elements:

1. A String representing a status code

2. A Hash that represents the headers and their values

3. An Array (or object that can be iterated over) that represents the body of the HTTP response.

Logic can be applied within the `call` method to "route".
Routing is the concept of using data from an HTTP response to figure out what web application or processes to perform in order to help generate the response.

---

Again, this is still a bit foggy, but I'm working on it.

If there's any critiques or extra tidbits anyone can offer, I would love to hear them! Thank you 😊Image

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Jack Sebben

Jack Sebben Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(