summaryrefslogtreecommitdiff
path: root/application.rb
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2010-05-21 15:58:31 +0200
committerChristoph Helma <helma@in-silico.ch>2010-05-21 15:58:31 +0200
commitacf5094b1eb8ee5cc105128dd16a1e330bd74864 (patch)
tree09091844e0d0aa46c6cbd8d3acedc49f1d8fed03 /application.rb
parent928ce9f7fda7cd650ba010efd7d86d739e565b6d (diff)
READMEs updated
Diffstat (limited to 'application.rb')
-rw-r--r--application.rb28
1 files changed, 16 insertions, 12 deletions
diff --git a/application.rb b/application.rb
index 73d1702..e19f680 100644
--- a/application.rb
+++ b/application.rb
@@ -23,7 +23,6 @@ get %r{/(.+)} do |inchi| # catches all remaining get requests
when "image/gif"
response['Content-Type'] = "image/gif"
OpenTox::Compound.new(:inchi => inchi).image
- #"#{CACTUS_URI}#{inchi}/image"
when "text/plain"
response['Content-Type'] = "text/plain"
uri = File.join CACTUS_URI,inchi,"names"
@@ -37,17 +36,22 @@ post '/?' do
input = request.env["rack.input"].read
response['Content-Type'] = 'text/uri-list'
- case request.content_type
- when /chemical\/x-daylight-smiles/
- OpenTox::Compound.new(:smiles => input).uri + "\n"
- when /chemical\/x-inchi/
- OpenTox::Compound.new(:inchi => input).uri + "\n"
- when /chemical\/x-mdl-sdfile|chemical\/x-mdl-molfile/
- OpenTox::Compound.new(:sdf => input).uri + "\n"
- when /text\/plain/
- OpenTox::Compound.new(:name => input).uri + "\n"
- else
+ begin
+ case request.content_type
+ when /chemical\/x-daylight-smiles/
+ OpenTox::Compound.new(:smiles => input).uri + "\n"
+ when /chemical\/x-inchi/
+ OpenTox::Compound.new(:inchi => input).uri + "\n"
+ when /chemical\/x-mdl-sdfile|chemical\/x-mdl-molfile/
+ OpenTox::Compound.new(:sdf => input).uri + "\n"
+ when /text\/plain/
+ OpenTox::Compound.new(:name => input).uri + "\n"
+ else
+ status 400
+ "Unsupported MIME type '#{request.content_type}'"
+ end
+ rescue
status 400
- "Unsupported MIME type '#{request.content_type}'"
+ "Cannot process request '#{input}' for content type '#{request.content_type}'"
end
end