Module: Utils::SensuHTTP
- Included in:
- Lita::Handlers::Sensu2
- Defined in:
- lib/utils/sensu_http.rb
Overview
Utility methods for making HTTP requests for Sensu
Instance Method Summary collapse
- #headers ⇒ Object
- #http_delete(url) ⇒ Object
- #http_get(url) ⇒ Object
- #http_post(url, data) ⇒ Object
- #silence_url ⇒ Object
Instance Method Details
#headers ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/utils/sensu_http.rb', line 4 def headers headers = {} if config.api_user creds = Base64.encode64("#{config.api_user.chomp}:#{config.api_pass.chomp}") headers['Authorization'] = "Basic #{creds}" end headers end |
#http_delete(url) ⇒ Object
19 20 21 22 23 |
# File 'lib/utils/sensu_http.rb', line 19 def http_delete(url) http.delete(url) do |req| req.headers = headers end end |
#http_get(url) ⇒ Object
13 14 15 16 17 |
# File 'lib/utils/sensu_http.rb', line 13 def http_get(url) http.get(url) do |req| req.headers = headers end end |
#http_post(url, data) ⇒ Object
25 26 27 28 29 |
# File 'lib/utils/sensu_http.rb', line 25 def http_post(url, data) http.post(url, data) do |req| req.headers = headers end end |
#silence_url ⇒ Object
31 32 33 |
# File 'lib/utils/sensu_http.rb', line 31 def silence_url "#{config.api_url}:#{config.api_port}/silenced" end |