Does someone know an elegant way to set the MIME content_type default to a non-HTML (and non-XML) value for an entire RAILS site without altering the RAILS base classes?
I am trying to flip a site to 'text/vnd.curl'.
Over at http://eclectic-pencil.blogspot.com/2009/10/curlgen-with-ruby-rails.html I have collected some notes on what I have learned so far.
My comments etc:
What I see in the code in pretty much typical of most web frameworks: sometimes the default is hard-coded to 'text/plain' and sometimes 'text/html' and in Rails it varies since there is Mime::HTML available.
The evil thought would be just to register my type as :html
But that fails because Mime::HTML is not always used: sometimes the hard-coded string is there.
Of course for individual controllers, there is no problem. Trickier is handling exceptional cases where the framework has no provision to flip the default type of Response either in the action-controller parent or in the Response class of the Rack module.
One day it will no longer be the norm for the web to return XHTML to a generic browser - but until then, 'text/html' will tend to be hard-coded in many places in many frameworks. There are a few frameworks evolving where it is simple to go non-HTML/non-XHTML. Very few.
Rails 3 should get beyond this, naturally.
Thanks