1

I want to return a string in response with content type as plain/text. This is what I am doing currently.

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

It says ;

RuntimeError - Unknown media type: :plain:
Jai Madhav
  • 603
  • 8
  • 17

1 Answers1

2

Provides take content_type from here: https://github.com/rack/rack/blob/master/lib/rack/mime.rb#L546

So the correct match is:

:provides => :text

Then you are also be able to set custom mime_types like:

get :index do
  content_type 'text/plain;charset=utf8'
  "Im plain"
end
DAddYE
  • 1,719
  • 11
  • 16
  • Note that if you're doing a Rack test, you may have to do `get '/foo.text'` (awkward). However, `:provides => :txt` is equivalent and allows `'/foo.txt'` instead. – Benjamin Oakes Mar 20 '12 at 15:04