Added timeout options for Faraday.
This commit is contained in:
parent
d6ebe079e6
commit
d7dd63ae4a
1 changed files with 1 additions and 1 deletions
|
@ -16,7 +16,7 @@ class GeoIp::Freegeoip
|
||||||
url = "/json/#{CGI::escape address}"
|
url = "/json/#{CGI::escape address}"
|
||||||
data = {}
|
data = {}
|
||||||
begin
|
begin
|
||||||
conn = Faraday.new( :url => host )
|
conn = Faraday.new( :url => host, :options => { :open_timeout => 2, :timeout => 5 } )
|
||||||
response = conn.get url
|
response = conn.get url
|
||||||
data = JSON.parse( response.body )
|
data = JSON.parse( response.body )
|
||||||
Cache.write( cache_key, data, { :expires_in => 90.days } )
|
Cache.write( cache_key, data, { :expires_in => 90.days } )
|
||||||
|
|
Loading…
Reference in a new issue