summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrautenberg <rautenberg@in-silico.ch>2015-05-20 18:05:11 +0200
committerrautenberg <rautenberg@in-silico.ch>2015-05-20 18:05:11 +0200
commita176fea6d081263b93a122ba5f377b8d21c19722 (patch)
tree6a8fc3ae4fdd4166793248e6da1eb074afbb6601
parent43e5c40c55c0cb039857ed9f05aa08c160a2686f (diff)
add basic CORS headers get, post, put
-rw-r--r--lib/opentox-server.rb1
-rw-r--r--lib/opentox.rb11
-rw-r--r--opentox-server.gemspec1
3 files changed, 13 insertions, 0 deletions
diff --git a/lib/opentox-server.rb b/lib/opentox-server.rb
index 5ff3c22..0202b44 100644
--- a/lib/opentox-server.rb
+++ b/lib/opentox-server.rb
@@ -1,5 +1,6 @@
require 'opentox-client'
require 'rack'
require 'rack/contrib'
+require 'rack/cors'
require 'sinatra'
["4store.rb", "opentox.rb", "authorization-helper.rb"].each {|f| require File.join(File.dirname(__FILE__),f) }
diff --git a/lib/opentox.rb b/lib/opentox.rb
index bd5415c..2adc04c 100644
--- a/lib/opentox.rb
+++ b/lib/opentox.rb
@@ -27,6 +27,17 @@ module OpenTox
also_reload File.join(ENV["HOME"],".opentox","config","#{SERVICE}.rb")
end
+ # add CORS support for swagger
+ use Rack::Cors do |config|
+ config.allow do |allow|
+ allow.origins '*'
+ allow.resource "/#{SERVICE}/*",
+ :methods => [:get, :post, :put ],
+ :headers => :any,
+ :max_age => 0
+ end
+ end
+
before do
@uri = uri(request.env['PATH_INFO']) # prevent /algorithm/algorithm in algorithm service
get_subjectid if respond_to? :get_subjectid
diff --git a/opentox-server.gemspec b/opentox-server.gemspec
index cc9d160..a38a860 100644
--- a/opentox-server.gemspec
+++ b/opentox-server.gemspec
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency "opentox-client"
s.add_runtime_dependency 'rack'
s.add_runtime_dependency 'rack-contrib'
+ s.add_runtime_dependency 'rack-cors'
s.add_runtime_dependency 'sinatra'
s.add_runtime_dependency 'sinatra-contrib'
s.add_runtime_dependency 'unicorn'