Browse files

Add recommended.ru example file.

  • Loading branch information...
1 parent 1859022 commit 3535e1c63030e663f21cc6963350f4c332cbe517 @mynyml committed Jun 4, 2009
Showing with 34 additions and 0 deletions.
  1. +34 −0 examples/recommended.ru
View
34 examples/recommended.ru
@@ -0,0 +1,34 @@
+# run me with:
+# $rackup examples/recommended.ru -p 3000
+#
+require 'pathname'
+require 'rubygems'
+require 'rack'
+require 'rack/abstract_format'
+
+root = Pathname(__FILE__).dirname.parent.expand_path
+require root + 'lib/rack/supported_media_types'
+
+class App
+ def call(env)
+ body = <<-BODY
+<pre>
+try using extensions:
+
+ - /foo.html
+ - /foo.xml
+ - /foo.json
+ - /foo.txt
+ - ...
+
+app will only accept .html and .xml requests. others will return 415
+(check server's output in console to see it)
+</pre>
+ BODY
+ [200, {'Content-Type' => 'text/html'}, [body]]
+ end
+end
+
+use Rack::AbstractFormat
+use Rack::SupportedMediaTypes, %w( text/html application/xml )
+run App.new

0 comments on commit 3535e1c

Please sign in to comment.