summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Helma <ch@in-silico.ch>2009-07-24 12:38:55 +0200
committerChristoph Helma <ch@in-silico.ch>2009-07-24 12:38:55 +0200
commitcf4caa7e243b80017105f8dee8f5a85c933692d7 (patch)
tree1d6e265d32b2015e1d7388386b6020afd432ff34
parentaa5e0284eb0d01694eff3e6b4f3aa7ddaaccbfbb (diff)
identifiers URI encoded, image_uri instaed of image
-rw-r--r--compounds.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/compounds.rb b/compounds.rb
index 7ec4c85..c1751c0 100644
--- a/compounds.rb
+++ b/compounds.rb
@@ -18,7 +18,7 @@ end
get '/*.*' do
begin
- identifier = params[:splat][0]
+ identifier = URI.encode(params[:splat][0])
format = params[:splat][1]
case format
when 'smiles'
@@ -32,7 +32,7 @@ get '/*.*' do
when 'names'
RestClient.get "#{CACTUS_URI}#{identifier}/names"
when 'image'
- RestClient.get "#{CACTUS_URI}#{identifier}/image"
+ "#{CACTUS_URI}#{identifier}/image"
else
status 400
"Cannot provide #{format}."
@@ -48,7 +48,7 @@ end
# default format is smiles
get '/:identifier' do
begin
- RestClient.get "#{CACTUS_URI}#{params[:identifier]}/smiles"
+ RestClient.get "#{CACTUS_URI}#{URI.encode(params[:identifier])}/smiles"
rescue
status 404
"Cannot find #{params[:identifier]}."
@@ -58,13 +58,13 @@ end
# return canonical uri
post '/' do
begin
- inchikey = RestClient.get "#{CACTUS_URI}#{params[:name]}/stdinchikey"
+ inchikey = RestClient.get "#{CACTUS_URI}#{URI.encode(params[:name])}/stdinchikey"
inchikey.chomp!
if inchikey.match(/\n/)
status 400
- "More than one structure found for #{params[:identifier]}."
+ "More than one structure found for #{params[:name]}."
else
- url_for("/", :full) + inchikey
+ url_for("/", :full) + URI.encode(inchikey)
end
rescue
status 500