diff options
author | Christoph Helma <helma@in-silico.de> | 2010-02-19 14:31:40 +0100 |
---|---|---|
committer | Christoph Helma <helma@in-silico.de> | 2010-02-19 14:31:40 +0100 |
commit | 38d3590c33e6e29553f5bc91b29a1a91b3174a44 (patch) | |
tree | 680a0ab4f745abc7399fd32d61d9c6d9934be4fd /application.rb | |
parent | 76a9e2d17c2130829d5772c9c8d55072ab40ab58 (diff) |
mime types added to response header
Diffstat (limited to 'application.rb')
-rw-r--r-- | application.rb | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/application.rb b/application.rb index db5b41e..74929dc 100644 --- a/application.rb +++ b/application.rb @@ -5,8 +5,7 @@ require 'opentox-ruby-api-wrapper' class Model include DataMapper::Resource property :id, Serial - property :uri, String, :length => 100 - #property :task_uri, String, :length => 100 + property :uri, String, :length => 255 property :owl, Text, :length => 2**32-1 property :yaml, Text, :length => 2**32-1 property :created_at, DateTime @@ -17,6 +16,7 @@ DataMapper.auto_upgrade! require 'lazar.rb' get '/?' do # get index of models + response['Content-Type'] = 'text/uri-list' Model.all.collect{|m| m.uri}.join("\n") end @@ -24,14 +24,16 @@ get '/:id/?' do model = Model.get(params[:id]) halt 404, "Model #{uri} not found." unless model accept = request.env['HTTP_ACCEPT'] - accept = "application/rdf+xml" if accept == '*/*' or accept == '' or accept.nil? + accept = "application/rdf+xml" if accept == '*/*' or accept =~ /html/ or accept == '' or accept.nil? case accept when "application/rdf+xml" + response['Content-Type'] = 'application/rdf+xml' model.owl when /yaml/ + response['Content-Type'] = 'application/x-yaml' model.yaml else - halt 400, "Unsupported MIME type '#{request.content_type}'" + halt 400, "Unsupported MIME type '#{accept}'" end end @@ -46,7 +48,8 @@ end delete '/?' do - #Model.all.each { |d| d.destroy! } + # TODO delete datasets Model.auto_migrate! + response['Content-Type'] = 'text/plain' "All Models deleted." end |