From 14c36869694a503acfb13d24d49a3738e39ef9e2 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Tue, 23 Apr 2019 14:31:01 +0200 Subject: [PATCH] ApiAdresse: add timeout --- app/lib/api_adresse/api.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/lib/api_adresse/api.rb b/app/lib/api_adresse/api.rb index 12cc8fdde..4470d9008 100644 --- a/app/lib/api_adresse/api.rb +++ b/app/lib/api_adresse/api.rb @@ -2,7 +2,10 @@ class ApiAdresse::API def self.call(address, limit = 1) search_url = [API_ADRESSE_URL, "search"].join("/") - RestClient.get(search_url, params: { q: address, limit: limit }) + RestClient::Request.execute(method: :get, + url: search_url, + timeout: 5, + headers: { params: { q: address, limit: limit } }) rescue RestClient::ServiceUnavailable nil end