Module: Bosh::Monitor::Plugins::HttpRequestHelper
- Included in:
- ConsulEventForwarder, Pagerduty, Resurrector
- Defined in:
- lib/bosh/monitor/plugins/http_request_helper.rb
Instance Method Summary collapse
- #send_http_get_request(uri) ⇒ Object
- #send_http_post_request(uri, request) ⇒ Object
- #send_http_put_request(uri, request) ⇒ Object
- #send_http_request(method, uri, request) ⇒ Object
Instance Method Details
#send_http_get_request(uri) ⇒ Object
13 14 15 16 17 |
# File 'lib/bosh/monitor/plugins/http_request_helper.rb', line 13 def send_http_get_request(uri) # we are interested in response, so send sync request logger.debug("Sending GET request to #{uri}") sync_client.get(uri) end |
#send_http_post_request(uri, request) ⇒ Object
5 6 7 |
# File 'lib/bosh/monitor/plugins/http_request_helper.rb', line 5 def send_http_post_request(uri, request) send_http_request(:post, uri, request) end |
#send_http_put_request(uri, request) ⇒ Object
9 10 11 |
# File 'lib/bosh/monitor/plugins/http_request_helper.rb', line 9 def send_http_put_request(uri, request) send_http_request(:put, uri, request) end |
#send_http_request(method, uri, request) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/bosh/monitor/plugins/http_request_helper.rb', line 19 def send_http_request(method, uri, request) name = self.class.name logger.debug("sending HTTP #{method.to_s.upcase} to: #{uri}") started = Time.now http = EM::HttpRequest.new(uri).send(method, request) http.callback do logger.debug("#{name} event sent (took #{Time.now - started} seconds): #{http.response_header.status}") end http.errback do |e| logger.error("Failed to send #{name} event: #{e.error}") end end |