Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View my_stack_content_type_neg_example.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
##### 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
Something went wrong with that request. Please try again.