mirror of
https://github.com/danbee/tube-status-server
synced 2025-03-04 08:39:12 +00:00
Add CORS and set JSON response type.
This commit is contained in:
parent
49a59a536f
commit
bb6e6612dc
@ -1 +1,2 @@
|
||||
export TUBESTATUS_FEED_EMAIL=
|
||||
export CORS_ALLOW_ORIGINS=
|
||||
|
||||
2
Gemfile
2
Gemfile
@ -6,6 +6,8 @@ gem 'faraday'
|
||||
gem 'xml-simple'
|
||||
gem 'foreman'
|
||||
|
||||
gem 'rack-cors'
|
||||
|
||||
gem 'newrelic_rpm'
|
||||
|
||||
group :development do
|
||||
|
||||
@ -12,6 +12,7 @@ GEM
|
||||
multipart-post (2.0.0)
|
||||
newrelic_rpm (3.10.0.279)
|
||||
rack (1.6.0)
|
||||
rack-cors (0.3.1)
|
||||
rack-protection (1.5.3)
|
||||
rack
|
||||
shotgun (0.9.1)
|
||||
@ -35,6 +36,7 @@ DEPENDENCIES
|
||||
faraday
|
||||
foreman
|
||||
newrelic_rpm
|
||||
rack-cors
|
||||
shotgun
|
||||
sinatra
|
||||
thin
|
||||
|
||||
@ -1,4 +1,12 @@
|
||||
require 'bundler'
|
||||
require 'rack/cors'
|
||||
|
||||
use Rack::Cors do
|
||||
allow do
|
||||
origins ENV['CORS_ALLOW_ORIGINS']
|
||||
resource '*', headers: :any
|
||||
end
|
||||
end
|
||||
|
||||
Bundler.setup
|
||||
require './tubestatus'
|
||||
|
||||
@ -29,6 +29,7 @@ class Tubestatus < Sinatra::Base
|
||||
:messages => line["StatusDetails"].empty? ? [] : [line["StatusDetails"]] }
|
||||
end
|
||||
|
||||
content_type :json
|
||||
JSON data
|
||||
end
|
||||
|
||||
@ -49,6 +50,7 @@ class Tubestatus < Sinatra::Base
|
||||
:messages => messages }
|
||||
end
|
||||
|
||||
content_type :json
|
||||
JSON data
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user