我想让Rack服务于具有特定内容类型的特定文件。它是一个.htc文件,需要作为text / x-component提供,以便IE识别它。在apache我会做
AddType text/x-component .htc
如何使用Rack实现这一目标?目前该文件由Rack :: Static提供,但我没有找到设置内容类型的选项。
答案 0 :(得分:14)
您可以像这样更新config/initializers/mime_types.rb
:
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone
Rack::Mime::MIME_TYPES.merge!({
".ogg" => "application/ogg",
".ogx" => "application/ogg",
".ogv" => "video/ogg",
".oga" => "audio/ogg",
".mp4" => "video/mp4",
".m4v" => "video/mp4",
".mp3" => "audio/mpeg",
".m4a" => "audio/mpeg",
".htc" => "text/x-component"
})
答案 1 :(得分:0)
或者只是回复问题,请在config/initializers/mime_types.rb
:
Mime::Type.register "text/x-component", :htc