mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
less verbose and more consistent requests
This commit is contained in:
parent
4529a3444f
commit
7a000a8e91
4 changed files with 8 additions and 19 deletions
|
@ -80,7 +80,7 @@ module Fog
|
|||
})
|
||||
|
||||
begin
|
||||
response = @connection.request({:host => @host}.merge!(params))
|
||||
response = @connection.request(params.merge!({:host => @host}))
|
||||
rescue Excon::Errors::Error => error
|
||||
case error
|
||||
when Excon::Errors::NotFound
|
||||
|
|
|
@ -94,18 +94,14 @@ module Fog
|
|||
|
||||
def cdn_request(params)
|
||||
@cdn_connection = Fog::Connection.new("#{@cdn_scheme}://#{@cdn_host}:#{@cdn_port}")
|
||||
response = @cdn_connection.request({
|
||||
:body => params[:body],
|
||||
:expects => params[:expects],
|
||||
response = @cdn_connection.request(params.merge!({
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'X-Auth-Token' => @auth_token
|
||||
}.merge!(params[:headers] || {}),
|
||||
:host => @cdn_host,
|
||||
:method => params[:method],
|
||||
:path => "#{@cdn_path}/#{params[:path]}",
|
||||
:query => params[:query]
|
||||
})
|
||||
}))
|
||||
unless response.body.empty?
|
||||
response.body = JSON.parse(response.body)
|
||||
end
|
||||
|
@ -114,18 +110,14 @@ module Fog
|
|||
|
||||
def storage_request(params, parse_json = true, &block)
|
||||
@storage_connection = Fog::Connection.new("#{@storage_scheme}://#{@storage_host}:#{@storage_port}")
|
||||
response = @storage_connection.request({
|
||||
:body => params[:body],
|
||||
:expects => params[:expects],
|
||||
response = @storage_connection.request(params.merge!({
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'X-Auth-Token' => @auth_token
|
||||
}.merge!(params[:headers] || {}),
|
||||
:host => @storage_host,
|
||||
:method => params[:method],
|
||||
:path => "#{@storage_path}/#{params[:path]}",
|
||||
:query => params[:query]
|
||||
}, &block)
|
||||
}), &block)
|
||||
if !response.body.empty? && parse_json
|
||||
response.body = JSON.parse(response.body)
|
||||
end
|
||||
|
|
|
@ -90,17 +90,14 @@ module Fog
|
|||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
|
||||
|
||||
begin
|
||||
response = @connection.request({
|
||||
:body => params[:body],
|
||||
:expects => params[:expects],
|
||||
response = @connection.request(params.merge!({
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'X-Auth-Token' => @auth_token
|
||||
}.merge!(params[:headers] || {}),
|
||||
:host => @host,
|
||||
:method => params[:method],
|
||||
:path => "#{@path}/#{params[:path]}"
|
||||
})
|
||||
}))
|
||||
rescue Excon::Errors::Error => error
|
||||
case error
|
||||
when Excon::Errors::NotFound
|
||||
|
|
|
@ -84,7 +84,7 @@ module Fog
|
|||
end
|
||||
|
||||
begin
|
||||
response = @connection.request({:host => @host}.merge!(params))
|
||||
response = @connection.request(params.merge!({:host => @host}))
|
||||
rescue Excon::Errors::Error => error
|
||||
case error
|
||||
when Excon::Errors::NotFound
|
||||
|
|
Loading…
Add table
Reference in a new issue