The minimal interface between Ruby web servers and web frameworks, with standard middleware
open sourceMITfree
Rack is the minimal, modular interface between Ruby web servers and web applications: an app is an object that takes the request environment and returns a status, headers and body, as the Rack Specification defines, so any conforming app runs unchanged on any supported server. Servers such as Puma, Falcon, Unicorn, Passenger, Pitchfork, Thin and NGINX Unit support it, and frameworks such as Ruby on Rails, Sinatra, Hanami, Roda and Padrino are built on it. The gem ships the specification, request and response helpers, a builder for composing apps from config.ru, and middleware for logging, conditional GET and ETags, gzip compression, content length and type, HEAD requests, method override, static files, locking and Rack::Lint conformance checks; sessions and the rackup command are separate gems. Rack 3.2 is current, 3.1 and 2.2 get security patches only (2.2 until 2027), and it's MIT-licensed.
Problems it solves
- write the smallest possible Ruby web app that runs on any server
- add middleware for gzip, ETags or logging to a Ruby web app
- build a Ruby web framework that works with Puma, Unicorn and other servers
- test that my Ruby web app conforms to the server interface
- upgrade a Rails app from Rack 2 to Rack 3
Features
- Rack Specification for apps, servers and middleware
- request and response helpers
- Rack::Builder and config.ru for composing apps
- middleware: CommonLogger, ConditionalGet, ETag, Deflater, ContentLength, ContentType, Head, MethodOverride, Static, Lock and more
- Rack::Lint conformance checks
- supported by Puma, Falcon, Unicorn, Passenger, Pitchfork, Thin, NGINX Unit, uWSGI and others
- used by Rails, Sinatra, Hanami, Roda, Padrino and others
Alternatives
The same job
These do what Rack does.
