lib/roda/plugins/sinatra_helpers.rb
# Set the Content-Type of the response body given a media type or file
# extension.  See plugin documentation for options.
Set the Content-Type of the response body given a media type or file
extension.  See plugin documentation for options.
Set the Content - Type of the response body given a media type or file extension . See plugin documentation for options .
def content_type(type = nil || (return @headers["Content-Type"]), opts = OPTS)
          unless (mime_type = mime_type(type) || opts[:default])
            raise RodaError, "Unknown media type: #{type}"
          end
          unless opts.empty?
            opts.each do |key, val|
              next if key == :default || (key == :charset && mime_type.include?('charset'))
              val = val.inspect if val =~ /[";,]/
              mime_type += "#{mime_type.include?(';') ? ', ' : ';'}#{key}=#{val}"
            end
          end
          @headers["Content-Type"] = mime_type
        end
def content_type ( type = nil || ( return @headers [ "Content-Type" ] ) , opts = OPTS ) unless ( mime_type = mime_type ( type ) || opts [ :default ] ) raise RodaError , "Unknown media type: #{type}" end unless opts . empty? opts . each do | key , val | next if key == :default || ( key == :charset && mime_type . include? ( 'charset' ) ) val = val . inspect if val =~ / [";,] / mime_type += "#{mime_type.include?(';') ? ', ' : ';'}#{key}=#{val}" end end @headers [ "Content-Type" ] = mime_type end
Set the Content-Type of the response body given a media type or file
extension.
Set the Content - Type of the response body given a media type or file extension .
type
opts