diff options
author | gebele <gebele@in-silico.ch> | 2018-07-05 10:38:55 +0000 |
---|---|---|
committer | gebele <gebele@in-silico.ch> | 2018-07-05 10:38:55 +0000 |
commit | 878f014ec6cc808af99af5045bcc1a1143cab8d9 (patch) | |
tree | 38458f73295d58c2ab487c81056d0abf0e4c4c19 /application.rb | |
parent | 395506ca3fe4daa5689fd197e57f7ab944beb1d7 (diff) |
updated with endpoint list; refined error handling; refined prediction input
Diffstat (limited to 'application.rb')
-rw-r--r-- | application.rb | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/application.rb b/application.rb index ebcb0af..a5f9ff2 100644 --- a/application.rb +++ b/application.rb @@ -7,6 +7,7 @@ include OpenTox "api.rb", "compound.rb", "dataset.rb", + "endpoint.rb", "feature.rb", "model.rb", "nanoparticle.rb", @@ -28,12 +29,13 @@ configure :development do end before do - paths = [ + $paths = [ "/", "aa", "api", "compound", "dataset", + "endpoint", "feature", "model", "nanoparticle", @@ -41,7 +43,7 @@ before do "substance", "swagger", "validation"] - if request.path == "/" || paths.include?(request.path.split("/")[1]) + if request.path == "/" || $paths.include?(request.path.split("/")[1]) @accept = request.env['HTTP_ACCEPT'] response['Content-Type'] = @accept else @@ -54,8 +56,14 @@ not_found do end error do - @error = request.env['sinatra.error'] - haml :error + if request.path == "/" || $paths.include?(request.path.split("/")[1]) + @accept = request.env['HTTP_ACCEPT'] + response['Content-Type'] = @accept + @accept == "text/plain" ? request.env['sinatra.error'] : request.env['sinatra.error'].to_json + else + @error = request.env['sinatra.error'] + haml :error + end end # https://github.com/britg/sinatra-cross_origin#responding-to-options |