如何在padrino中将内容类型设置为plain / text?

时间:2011-11-10 05:20:30

标签: content-type runtime-error plaintext padrino media-type

我想返回一个字符串作为响应,内容类型为plain / text。这就是我目前正在做的事情。

 get :index, :map => "/ivr", :provides => [:plain]  do
   "Hello World!"
 end

它说;

RuntimeError - Unknown media type: :plain:

1 个答案:

答案 0 :(得分:2)

从此处提供take content_type:https://github.com/rack/rack/blob/master/lib/rack/mime.rb#L546

所以正确匹配是:

:provides => :text

然后您还可以设置自定义mime_types,如:

get :index do
  content_type 'text/plain;charset=utf8'
  "Im plain"
end
相关问题