diff options
author | root <root@ot-dev.in-silico.ch> | 2011-02-24 11:59:56 +0000 |
---|---|---|
committer | root <root@ot-dev.in-silico.ch> | 2011-02-24 11:59:56 +0000 |
commit | 2b61ab65d17b6c80b0afdee33956c263cd7f9c21 (patch) | |
tree | 5854f67ec8473f38eaf5f29e28a98b5fb3027dcd | |
parent | 65e03beed272c0287afcfd0daeeba57f71e55999 (diff) |
set :lock, true in config_ru.rb, detect accept header in before filter
-rw-r--r-- | lib/config/config_ru.rb | 1 | ||||
-rw-r--r-- | lib/helper.rb | 20 |
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/config/config_ru.rb b/lib/config/config_ru.rb index 3d8dce2..93df867 100644 --- a/lib/config/config_ru.rb +++ b/lib/config/config_ru.rb @@ -12,6 +12,7 @@ $stdout.sync = true $stderr.sync = true set :logging, false set :raise_errors, true +set :lock, true ['public','tmp'].each do |dir| FileUtils.mkdir_p dir unless File.exists?(dir) diff --git a/lib/helper.rb b/lib/helper.rb index b30908c..37238bd 100644 --- a/lib/helper.rb +++ b/lib/helper.rb @@ -61,6 +61,26 @@ before do end @subjectid = subjectid protected!(subjectid) + + extension = File.extname(request.path_info) # params[:id] is not yet available + unless extension.empty? + #request.path_info.sub!(/\.#{extension}$/,'') + case extension + when "html" + @accept = 'text/html' + when "yaml" + @accept = 'application/x-yaml' + when "csv" + @accept = 'text/csv' + when "rdfxml" + @accept = 'application/rdf+xml' + when "xls" + @accept = 'application/ms-excel' + else + halt 404, "File format #{extension} not supported." + end + end + end end |