我想让 Rack 提供具有特定内容类型的特定文件。这是一个 .htc 文件,它需要作为 text/x-component 提供,以便 IE 能够识别它。在阿帕奇我会做
AddType text/x-component .htc
如何使用 Rack 实现这一目标?目前该文件由 Rack::Static 提供,但我没有找到设置内容类型的选项。
我想让 Rack 提供具有特定内容类型的特定文件。这是一个 .htc 文件,它需要作为 text/x-component 提供,以便 IE 能够识别它。在阿帕奇我会做
AddType text/x-component .htc
如何使用 Rack 实现这一目标?目前该文件由 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