Search code examples
content-typeruntime-errorplaintextpadrinomedia-type

How to set content type as plain/text in padrino?


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:

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