From 63d391467814b60f165075f32a0adbe33cced67b Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 23 Aug 2011 12:04:51 +0200 Subject: fix output for fileextensions on curl requests --- application.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/application.rb b/application.rb index 96287c3..0b6b851 100644 --- a/application.rb +++ b/application.rb @@ -26,6 +26,20 @@ before do @uri = uri @id @yaml_file = "#{@@datadir}/#{@id}.yaml" raise OpenTox::NotFoundError.new "Model #{@id} not found." unless File.exists? @yaml_file + + extension = File.extname(request.path_info) + unless extension.empty? + case extension + when ".html" + @accept = 'text/html' + when ".yaml" + @accept = 'application/x-yaml' + when ".rdfxml" + @accept = 'application/rdf+xml' + else + raise OpenTox::NotFoundError.new "File format #{extension} not supported." + end + end end # make sure subjectid is not included in params, subjectid is set as member variable -- cgit v1.2.3