Rack (web server interface)

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Dvyjones (talk | contribs) at 21:38, 2 August 2009 (Added an example application). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Rack, a Ruby Webserver Interface
Stable release
1.0.0 / May 25, 2009 (2009-05-25)
Repository
Operating systemCross-platform
TypeMiddleware
LicenseMIT License
Websitehttp://rack.rubyforge.org/

Rack provides a minimal, modular and adaptable interface for developing web applications in Ruby. By wrapping HTTP requests and responses in the simplest way possible, it unifies and distills the API for web servers, web frameworks, and software in between (the so-called middleware) into a single method call.

Example Application

A Rack-compatible "Hello World" application in Ruby syntax:

require 'rack'
app = Rack::Builder.app do 
  lambda do |env|
    body = "Hello, World!"
    [200, {"Content-Type" => "text/plain", "Content-Length" => body.length.to_s}, [body]]
  end
end

External links