我想让Rack提供特定内容类型的特定文件。它是一个.htc文件,它需要作为text/x-component使用,以便IE能识别它。在阿帕奇我只是做如何使用Rack为特定文件设置内容类型?
AddType text/x-component .htc
我怎样才能实现这一点与机架?目前该文件由Rack :: Static提供,但我没有找到设置内容类型的选项。
我想让Rack提供特定内容类型的特定文件。它是一个.htc文件,它需要作为text/x-component使用,以便IE能识别它。在阿帕奇我只是做如何使用Rack为特定文件设置内容类型?
AddType text/x-component .htc
我怎样才能实现这一点与机架?目前该文件由Rack :: Static提供,但我没有找到设置内容类型的选项。
您可以更新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"
})
或者只是回答的问题,在config/initializers/mime_types.rb
补充一点:
Mime::Type.register "text/x-component", :htc
这奏效了,谢谢!我没有mime_types.rb,所以我把它直接放到config.ru文件中。 – 2010-07-22 14:27:40
对不起,确定你没有一个,它来自铁轨,但由于铁轨是一个架子,它的工作原理。 – jigfox 2010-07-22 15:26:22
通常我的Rack项目没有config/initializers目录,只有我的rails项目有... – Phillipp 2016-06-30 17:05:46