Question

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:
Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top