Rack Mimetypes

rack

Sat Jun 20 21:20:01 -0700 2009

When a Rack-based framework (Rails >= 2.3, Sinatra, etc) serves a static file, it uses the Rack mimetimes hash to map the file’s extension to the Content-Type header on the response. For example, serving text/plain for .txt, or image/jpeg for .jpg.

Although there doesn’t appear to be any official interface for adding to the list of mimetypes, you can tinker with the hash directly during your app’s boot process. For example:

Rack::Mime::MIME_TYPES[".air"] = "application/vnd.adobe.air-application-installer-package+zip"

(Via Blake Mizerany.)