1
0
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:
Daniel Barber 2015-03-06 14:03:11 +00:00
parent 49a59a536f
commit bb6e6612dc
5 changed files with 15 additions and 0 deletions

View File

@ -1 +1,2 @@
export TUBESTATUS_FEED_EMAIL=
export CORS_ALLOW_ORIGINS=

View File

@ -6,6 +6,8 @@ gem 'faraday'
gem 'xml-simple'
gem 'foreman'
gem 'rack-cors'
gem 'newrelic_rpm'
group :development do

View File

@ -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

View File

@ -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'

View File

@ -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