diff options
author | rautenberg <rautenberg@in-silico.ch> | 2015-06-02 18:51:49 +0200 |
---|---|---|
committer | rautenberg <rautenberg@in-silico.ch> | 2015-06-02 18:51:49 +0200 |
commit | 012eb548d764eb76b1a21f40c3af97467a013d49 (patch) | |
tree | 50df962312b4055cf906f6f5c74b06ca1565d58f | |
parent | 5aafb77fdb5c456feb7ee8b0a25a7a35935b7d3d (diff) |
add switch to enable CORS support
-rw-r--r-- | lib/opentox.rb | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/opentox.rb b/lib/opentox.rb index ebd2338..be248b6 100644 --- a/lib/opentox.rb +++ b/lib/opentox.rb @@ -28,13 +28,15 @@ module OpenTox end # add CORS support for swagger - use Rack::Cors do |config| - config.allow do |allow| - allow.origins '*' - allow.resource "/#{SERVICE}/*", - :methods => [:head, :get, :post, :put, :options], - :headers => :any, - :max_age => 0 + if eval("$#{SERVICE}[:cors]") == true + use Rack::Cors do |config| + config.allow do |allow| + allow.origins '*' + allow.resource "/#{SERVICE}/", + :methods => [:head, :get, :post, :put, :delete, :options], + :headers => :any, + :max_age => 0 + end end end |