This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
| name | age | message | |
|---|---|---|---|
| |
.gitignore | ||
| |
LICENSE | ||
| |
README | ||
| |
Rakefile | ||
| |
examples/ | ||
| |
lib/ | ||
| |
rack-supported-media-types.gemspec | ||
| |
test/ |
README
===== Summary Rack middleware to specify an app's supported media types. Returns '406 Not Acceptable' status when unsuported type is requested. The requested type is assumed to be the first content-type in the Accept header's list. ===== Install gem install mynyml-rack-supported-media-types --source=http://gems.github.com/ ===== Example require 'rack' require 'rack/supported_media_types' use Rack::SupportedMediaTypes, %w( application/xml application/json ) run App.new will give you: GET /foo Accept: text/html,text/plain #=> 406 Not Acceptable GET /foo Accept: application/xml,text/html #=> 200 OK GET /foo Accept: application/json,text/html #=> 200 OK see examples/simple.ru for example code. ===== Tip To read the requested type from the url's extension instead of the Accept header (which is a more realistic use case), use Rack::AbstractFormat before Rack::SupportedMediaTypes. # gem install mynyml-rack-abstract-format --source=http://gems.github.com/ require 'rack' require 'rack/abstract_format' require 'rack/supported_media_types' use Rack::AbstractFormat use Rack::SupportedMediaTypes, %w( application/xml application/json ) run App.new will result in: GET /foo.html #=> 406 Not Acceptable GET /foo.xml #=> 200 OK GET /foo.json #=> 200 OK (Rack::AbstractFormat prepends the media type for the url's extension to the Accept header) see examples/recommended.ru for example code. ===== Links source:: http://github.com/mynyml/rack-supported-media-types rdocs:: http://docs.github.com/mynyml/rack-supported-media-types








