public
Description: Rack middleware that abstracts format (extension) away from the path (into env)
Homepage:
Clone URL: git://github.com/mynyml/rack-abstract-format.git
name age message
file .gitignore Tue Jun 02 13:33:22 -0700 2009 Prepend format (as media type) to Accept header... [mynyml]
file LICENSE Thu May 21 08:12:27 -0700 2009 Initial commit. [mynyml]
file README Wed Jun 03 06:34:00 -0700 2009 Update README [mynyml]
file Rakefile Mon Jun 08 13:11:16 -0700 2009 v0.9.7 [mynyml]
directory examples/ Mon Jun 08 13:10:44 -0700 2009 Update example file's docs. [mynyml]
directory lib/ Mon Jun 08 13:03:03 -0700 2009 Fix handling of extension-less paths. [mynyml]
file rack-abstract-format.gemspec Mon Jun 08 13:11:16 -0700 2009 v0.9.7 [mynyml]
directory test/ Mon Jun 08 13:03:03 -0700 2009 Fix handling of extension-less paths. [mynyml]
README
===== Summary

Strips the extension from the requested path (env['PATH_INFO']), casts it to
media type, and prepends it to env['HTTP_ACCEPT']. This allows dealing with path
information separately from format information, which are often different
concerns.

This is especially useful when dealing with routes as it allows a resource to
always point to the same action independently from the requested format.

===== Usage

require 'rack'
require 'rack/abstract_format'

use Rack::AbstractFormat
run app

The request:

  GET /path/resource.xml
  Accept: text/html

will become:

  GET /path/resource
  env['HTTP_ACCEPT'] #=> 'application/xml,text/html'