Merge branch 'master' into stable
This commit is contained in:
commit
64e6dc7992
2
Gemfile
2
Gemfile
@ -17,5 +17,5 @@ end
|
|||||||
|
|
||||||
group :staging, :production do
|
group :staging, :production do
|
||||||
gem "rainbows"
|
gem "rainbows"
|
||||||
gem "sentry-raven"
|
gem "sentry-raven", require: false
|
||||||
end
|
end
|
||||||
|
@ -22,7 +22,6 @@ GEM
|
|||||||
backports (3.6.4)
|
backports (3.6.4)
|
||||||
beefcake (0.3.7)
|
beefcake (0.3.7)
|
||||||
builder (3.2.2)
|
builder (3.2.2)
|
||||||
certifi (2015.08.10)
|
|
||||||
domain_name (0.5.24)
|
domain_name (0.5.24)
|
||||||
unf (>= 0.0.5, < 1.0.0)
|
unf (>= 0.0.5, < 1.0.0)
|
||||||
excon (0.16.10)
|
excon (0.16.10)
|
||||||
@ -77,8 +76,7 @@ GEM
|
|||||||
mime-types (>= 1.16, < 3.0)
|
mime-types (>= 1.16, < 3.0)
|
||||||
netrc (~> 0.7)
|
netrc (~> 0.7)
|
||||||
ruby-hmac (0.4.0)
|
ruby-hmac (0.4.0)
|
||||||
sentry-raven (0.14.0)
|
sentry-raven (0.15.2)
|
||||||
certifi
|
|
||||||
faraday (>= 0.7.6)
|
faraday (>= 0.7.6)
|
||||||
sinatra (1.4.6)
|
sinatra (1.4.6)
|
||||||
rack (~> 1.4)
|
rack (~> 1.4)
|
||||||
|
@ -317,19 +317,27 @@ module RemoteStorage
|
|||||||
end
|
end
|
||||||
|
|
||||||
def do_put_request(url, data, content_type)
|
def do_put_request(url, data, content_type)
|
||||||
RestClient.put(url, data, default_headers.merge({content_type: content_type}))
|
deal_with_unauthorized_requests do
|
||||||
|
RestClient.put(url, data, default_headers.merge({content_type: content_type}))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def do_get_request(url, &block)
|
def do_get_request(url, &block)
|
||||||
RestClient.get(url, default_headers, &block)
|
deal_with_unauthorized_requests do
|
||||||
|
RestClient.get(url, default_headers, &block)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def do_head_request(url, &block)
|
def do_head_request(url, &block)
|
||||||
RestClient.head(url, default_headers, &block)
|
deal_with_unauthorized_requests do
|
||||||
|
RestClient.head(url, default_headers, &block)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def do_delete_request(url)
|
def do_delete_request(url)
|
||||||
RestClient.delete(url, default_headers)
|
deal_with_unauthorized_requests do
|
||||||
|
RestClient.delete(url, default_headers)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def escape(url)
|
def escape(url)
|
||||||
@ -367,5 +375,18 @@ module RemoteStorage
|
|||||||
|
|
||||||
settings.swift_token
|
settings.swift_token
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def deal_with_unauthorized_requests(&block)
|
||||||
|
begin
|
||||||
|
block.call
|
||||||
|
rescue RestClient::Unauthorized => ex
|
||||||
|
Raven.capture_exception(
|
||||||
|
ex,
|
||||||
|
tags: { swift_token: settings.swift_token,
|
||||||
|
swift_token_loaded_at: settings.swift_token_loaded_at }
|
||||||
|
)
|
||||||
|
server.halt 500
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -39,7 +39,8 @@ class LiquorCabinet < Sinatra::Base
|
|||||||
|
|
||||||
configure :production, :staging do
|
configure :production, :staging do
|
||||||
if ENV['SENTRY_DSN']
|
if ENV['SENTRY_DSN']
|
||||||
require "raven"
|
require "raven/base"
|
||||||
|
require "raven/integrations/rack"
|
||||||
|
|
||||||
Raven.configure do |config|
|
Raven.configure do |config|
|
||||||
config.dsn = ENV['SENTRY_DSN']
|
config.dsn = ENV['SENTRY_DSN']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user