Module: Mojito::Rendering::ContentTypes

Defined in:
lib/mojito/rendering/content_types.rb

Instance Method Summary collapse

Instance Method Details

#content_type(type = :html, charset = 'UTF-8') ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/mojito/rendering/content_types.rb', line 8

def content_type(type = :html, charset = 'UTF-8')
	t = case type
	when :plain
		MIME::Types.type_for 'txt'
	else
		MIME::Types.type_for type.to_s
	end.first
	response['Content-Type'] = t.to_s + (t.ascii? ? "; charset=#{charset}" : '')
end