Fixed content-type for .json files

Content-type is now 'application/json'
This commit is contained in:
bcoles
2011-12-27 19:37:57 +10:30
parent 3ec19fec99
commit 9b4a24c676

View File

@@ -76,11 +76,14 @@ module AdminUI
template_ui = "#{$root_dir}/extensions/admin_ui/controllers/#{class_s}/#{function_name}.html"
@eruby = Erubis::FastEruby.new(File.read(template_ui)) if File.exists? template_ui # load the template file
@body = @eruby.result(binding()) if not @eruby.nil? # apply template and set the response
# set appropriate content-type 'application/json' for .json files
@headers['Content-Type']='application/json; charset=UTF-8' if request.path =~ /\.json$/
# set content type
if @headers['Content-Type'].nil?
@headers['Content-Type']='text/html; charset=UTF-8' # default content and charset type for all pages
@headers['Content-Type']='application/json; charset=UTF-8' if request.path =~ /.json$/
@headers['Content-Type']='application/json; charset=UTF-8' if request.path =~ /\.json$/
end
end