chore: Add timeouts to requests (#2024)

This commit is contained in:
Sojan Jose
2021-03-31 16:39:57 +05:30
committed by GitHub
parent f5a961b27c
commit c8b81b066b
5 changed files with 24 additions and 10 deletions

View File

@@ -1,6 +1,11 @@
class Webhooks::Trigger
def self.execute(url, payload)
RestClient.post(url, payload.to_json, { content_type: :json, accept: :json })
RestClient::Request.execute(
method: :post,
url: url, payload: payload.to_json,
headers: { content_type: :json, accept: :json },
timeout: 5
)
rescue *ExceptionList::REST_CLIENT_EXCEPTIONS, *ExceptionList::URI_EXCEPTIONS => e
Rails.logger.info "Exception: invalid webhook url #{url} : #{e.message}"
rescue StandardError => e