drnic / rack-contrib forked from rack/rack-contrib

Contributed Rack Middleware and Utilities

This URL has Read+Write access

drnic (author)
Sat May 09 19:25:53 -0700 2009
commit  a8b23aceb933c8933bf8505ad78504b1feed0615
tree    5c5cff26267fa34dc9cf8c25d107937c8dd4f124
parent  b8d99608d783b2843abc2ff7a6638d34f2a611d6
name age message
file .gitignore Mon Dec 08 21:22:46 -0800 2008 Add gemspec for github builds and clean up Rake... [rtomayko]
file COPYING Sun Nov 30 21:28:09 -0800 2008 boilerplate files; rack/contrib.rb and spec_rac... [rtomayko]
file README.rdoc Loading commit data...
file Rakefile Sat Mar 07 03:56:05 -0800 2009 Add 'rake spec' task [rtomayko]
directory lib/
file rack-contrib.gemspec
directory test/
README.rdoc

Contributed Rack Middleware and Utilities

This package includes a variety of add-on components for Rack, a Ruby web server interface:

  • Rack::ETag - Automatically sets the ETag header on all String bodies.
  • Rack::JSONP - Adds JSON-P support by stripping out the callback param and padding the response with the appropriate callback format.
  • Rack::LighttpdScriptNameFix - Fixes how lighttpd sets the SCRIPT_NAME and PATH_INFO variables in certain configurations.
  • Rack::Locale - Detects the client locale using the Accept-Language request header and sets a rack.locale variable in the environment.
  • Rack::MailExceptions - Rescues exceptions raised from the app and sends a useful email with the exception, stacktrace, and contents of the environment.
  • Rack::NestedParams - parses form params with subscripts (e.g., * "post[title]=Hello") into a nested/recursive Hash structure (based on Rails’ implementation).
  • Rack::PostBodyContentTypeParser - Adds support for JSON request bodies. The Rack parameter hash is populated by deserializing the JSON data provided in the request body when the Content-Type is application/json.
  • Rack::ProcTitle - Displays request information in process title ($0) for monitoring/inspection with ps(1).
  • Rack::Profiler - Uses ruby-prof to measure request time.
  • Rack::Sendfile - Enables X-Sendfile support for bodies that can be served from file.
  • Rack::Signals - Installs signal handlers that are safely processed after a request
  • Rack::TimeZone - Detects the clients timezone using JavaScript and sets a variable in Rack’s environment with the offset from UTC.
  • Rack::Evil - Lets the rack application return a response to the client from any place.
  • Rack::Callbacks - Implements DLS for pure before/after filter like Middlewares.
  • Rack::Config - Shared configuration for cooperative middleware.
  • Rack::NotFound - A default 404 application.
  • Rack::CSSHTTPRequest - Adds CSSHTTPRequest support by encoding responses as CSS for cross-site AJAX-style data loading
  • Rack::Deflect - Helps protect against DoS attacks.
  • Rack::ResponseCache - Caches responses to requests without query strings to Disk or a user provider Ruby object. Similar to Rails’ page caching.
  • Rack::RelativeRedirect - Transforms relative paths in redirects to absolute URLs.
  • Rack::Backstage - Returns content of specified file if it exists, which makes it convenient for putting up maintenance pages.
  • Rack::Format - Adds a format extension at the end of the URI when there is none, corresponding to the mime-type given in the Accept HTTP header.
  • Rack::HostMeta - Configures /host-meta using a block
  • Rack::ProbablyVersioned - Supports a /v1/ prefix to all routes; removing it and forwarding remaining route to remainder of app.

Use

Git is the quickest way to the rack-contrib sources:

  git clone git://github.com/rack/rack-contrib.git

Gems are currently available from GitHub clones:

  gem install rack-rack-contrib --source=http://gems.github.com/

Requiring ‘rack/contrib’ will add autoloads to the Rack modules for all of the components included. The following example shows what a simple rackup (+config.ru+) file might look like:

  require 'rack'
  require 'rack/contrib'

  use Rack::Profiler if ENV['RACK_ENV'] == 'development'

  use Rack::ETag
  use Rack::MailExceptions

  run theapp

Links

rack-contrib on GitHub:<github.com/rack/rack-contrib>
Rack:<rack.rubyforge.org/>
Rack On GitHub:<github.org/rack/rack>
rack-devel mailing list:<groups.google.com/group/rack-devel>