The Rack gem provides the infrastructure code that you can use to build your own web application, web framework, or middleware. It allows to quickly prototype or build stuff without doing the same repetitive tasks again and again.
Here are some helpers you can use with Rack:
Rack::Request
, which also provides query string parsing and multipart handling.Rack::Response
, for convenient generation of HTTP replies and cookie handling.Rack::MockRequest
andRack::MockResponse
for efficient and quick testing of Rack application without real HTTP round-trips.Rack::Cascade
, for trying additional Rack applications if an application returns anot found (404)
ormethod not supported (405)
response.Rack::Directory
, for serving files under a given directory, with directory indexes.Rack::MediaType
, for parsing content-type headers.Rack::Mime
, for determining content-type based on file extension.Since the Rack interface is so simple, anyone can build and publish useful middleware, and the community did build many such components.
The rack-contrib
project on Github contains a library of these middleware components. Take a look; you will definitely find something useful.