Created
November 9, 2009 08:35
-
-
Save hassox/229790 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##### ContentType negotiation | |
# Add a mime type | |
Pancake::MimeTypes::Type.new("foo", "text/foo") | |
Pancake::MimeTypes::Type.new("special", "text/plain") | |
# Group mime types together to simplify responding | |
Pancake::MimeTypes.group_as(:html, "xhtml", "foo") | |
Pancake::MimeTypes.group_as(:special, "special", "log") | |
# Low level usage | |
Pancake::MimeType.negotiate_accept_type(accept_type, :html, :special) | |
# Use in a short stack | |
class MyShortStack < Pancake::Stacks::Short | |
provides :html, :special | |
get "/foo(.:format)" do | |
case content_type | |
when :html | |
# respond with html | |
when :special | |
# respond with special | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment