Rack

What is Rack

Rack provides a minimal interface between webservers supporting Ruby and Ruby frameworks.

Source: http://rack.github.io

What does that mean?

Unified interface for all Ruby webservers to implement.

Rack Spec

Environment

Where does the code go?

Simplest Example

curl -i localhost:5000

Simplest Example

Simple Rack App

Middleware

Middleware

Basic Middleware

Middleware

curl -i localhost:5200

ContentLength Middleware

ContentLength Middleware

$ rake middleware

Adding Middleware - config.ru

Adding Middleware - Rails

Rails Router

The Rails Router uses the same principle, every action is a Rack app

Rails Router

Rack in the "field"

http://www.flickr.com/photos/arturstaszewski/7048604301

Normal API POST Request

API Normal

iPad Drops Connection

API Dropped

Desired Results

API Dedup

How can we solve this?

Idempotent Post Middleware

Idempotent Post Middleware

Testing Middleware

Other ways to use Middleware

Rack Cache

1st Request to Cache

Cache First Request

2nd Request to Cache

Cache Second Request

Rack Cache Example

curl -i localhost:5300

Rack Cache in Rails

Rack Cache

Cucumber Test Login Backdoor

Cucumber Test Login Backdoor

Cucumber Test Login Backdoor

Compression

Compression

curl -i localhost:5400 | wc -c
curl -i -H 'Accept-Encoding: gzip' localhost:5400 | wc -c

Compression

curl -i localhost:5500 | wc -c
curl -i -H 'Accept-Encoding: gzip' localhost:5500 | wc -c

Compression Resources

Resources

Making Life Better

http://www.flickr.com/photos/mdpettitt/6808986687

Questions

Feedback

#

/