mirror of
https://github.com/hakanensari/frankfurter.git
synced 2024-11-21 18:42:29 +01:00
Refactor cross-origin
- Drop cross_origin gem - Add header to all responses #18
This commit is contained in:
parent
ae0e9a009a
commit
1d059cd049
1
Gemfile
1
Gemfile
@ -9,7 +9,6 @@ gem 'newrelic_rpm'
|
||||
gem 'rake'
|
||||
gem 'sequel_pg'
|
||||
gem 'sinatra-jsonp'
|
||||
gem 'sinatra-cross_origin'
|
||||
gem 'unicorn'
|
||||
gem 'yajl-ruby'
|
||||
|
||||
|
@ -41,7 +41,6 @@ GEM
|
||||
rack (~> 1.5)
|
||||
rack-protection (~> 1.4)
|
||||
tilt (>= 1.3, < 3)
|
||||
sinatra-cross_origin (0.3.2)
|
||||
sinatra-jsonp (0.4.4)
|
||||
multi_json (~> 1.8)
|
||||
sinatra (~> 1.0)
|
||||
@ -65,7 +64,6 @@ DEPENDENCIES
|
||||
rake
|
||||
sequel_pg
|
||||
shotgun
|
||||
sinatra-cross_origin
|
||||
sinatra-jsonp
|
||||
unicorn
|
||||
yajl-ruby
|
||||
|
@ -1,7 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'sinatra'
|
||||
require 'sinatra/cross_origin'
|
||||
require 'sinatra/jsonp'
|
||||
require 'yajl'
|
||||
require 'quote'
|
||||
@ -44,6 +43,10 @@ helpers do
|
||||
end
|
||||
end
|
||||
|
||||
before do
|
||||
headers 'Access-Control-Allow-Origin' => '*'
|
||||
end
|
||||
|
||||
get '/' do
|
||||
jsonp details: 'http://fixer.io', version: App.version
|
||||
end
|
||||
|
@ -53,7 +53,9 @@ describe 'the API' do
|
||||
end
|
||||
|
||||
it 'allows cross-origin requests' do
|
||||
get '/', {}, 'HTTP_ORIGIN' => 'http://localhost'
|
||||
assert_equal 'http://localhost', headers['Access-Control-Allow-Origin']
|
||||
%w(/ /latest /2012-11-20).each do |path|
|
||||
get path
|
||||
assert_equal '*', headers['Access-Control-Allow-Origin']
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user