diff options
author | mr <mr@mrautenberg.de> | 2011-08-23 12:04:51 +0200 |
---|---|---|
committer | mr <mr@mrautenberg.de> | 2011-08-23 12:04:51 +0200 |
commit | 63d391467814b60f165075f32a0adbe33cced67b (patch) | |
tree | 59ad6b9ac976f8cdf0ccfcc412c3c335984a6f63 /application.rb | |
parent | a368d3ad8015a905c0aee873c5c10c2fad4afbdb (diff) |
fix output for fileextensions on curl requests
Diffstat (limited to 'application.rb')
-rw-r--r-- | application.rb | 14 |
1 files changed, 14 insertions, 0 deletions
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 |