From 395506ca3fe4daa5689fd197e57f7ab944beb1d7 Mon Sep 17 00:00:00 2001 From: gebele Date: Thu, 28 Jun 2018 14:35:20 +0000 Subject: updated API and request path handling --- application.rb | 53 +++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 26 deletions(-) (limited to 'application.rb') diff --git a/application.rb b/application.rb index 96e564b..ebcb0af 100644 --- a/application.rb +++ b/application.rb @@ -2,6 +2,20 @@ require 'rdiscount' require_relative 'qmrf_report.rb' include OpenTox +[ + "aa.rb", + "api.rb", + "compound.rb", + "dataset.rb", + "feature.rb", + "model.rb", + "nanoparticle.rb", + "report.rb", + "substance.rb", + "swagger.rb", + "validation.rb" +].each{ |f| require_relative "./lib/#{f}" } + configure :production do $logger = Logger.new(STDOUT) @@ -15,18 +29,19 @@ end before do paths = [ - "/aa", - "/api", - "/compound", - "/dataset", - "/feature", - "/model", - "/nanoparticle", - "/report", - "/substance", - "/swagger", - "/validation"] - if paths.include?(request.path) + "/", + "aa", + "api", + "compound", + "dataset", + "feature", + "model", + "nanoparticle", + "report", + "substance", + "swagger", + "validation"] + if request.path == "/" || paths.include?(request.path.split("/")[1]) @accept = request.env['HTTP_ACCEPT'] response['Content-Type'] = @accept else @@ -50,20 +65,6 @@ options "*" do 200 end -[ - "aa.rb", - "api.rb", - "compound.rb", - "dataset.rb", - "feature.rb", - "model.rb", - "nanoparticle.rb", - "report.rb", - "substance.rb", - "swagger.rb", - "validation.rb" -].each{ |f| require_relative "./lib/#{f}" } - get '/predict/?' do @models = OpenTox::Model::Validation.all @models = @models.delete_if{|m| m.model.name =~ /\b(Net cell association)\b/} -- cgit v1.2.3