Class: Hiera::Backend::Eyaml::Encryptors::Vault_rs::Httphandler
- Inherits:
-
Object
- Object
- Hiera::Backend::Eyaml::Encryptors::Vault_rs::Httphandler
- Defined in:
- lib/hiera/backend/eyaml/encryptors/vault_rs/httphandler.rb
Class Method Summary collapse
- .http_send(uri, request, headers = {}, options = {}) ⇒ Object
- .post(uri_str, data = {}, headers = {}, options = {}) ⇒ Object
- .put(uri_str, data = {}, headers = {}, options = {}) ⇒ Object
Class Method Details
.http_send(uri, request, headers = {}, options = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/hiera/backend/eyaml/encryptors/vault_rs/httphandler.rb', line 30 def http_send(uri, request, headers={}, ={}) request.add_field('Content-Type', [:content_type]) if [:content_type] headers.each do |header, value| request.add_field(header, value) end http = Net::HTTP.new(uri.host, uri.port) if [:ssl] http.use_ssl = true http.verify_mode = [:ssl_verify] ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE http.cert = OpenSSL::X509::Certificate.new([:ssl_cert]) if [:ssl_cert] http.key = OpenSSL::PKey::RSA.new([:ssl_key]) if [:ssl_key] http.ca_file = [:ca_file] if [:ca_file] end begin response = http.request(request) return response rescue => e raise HTTPError, e. end end |
.post(uri_str, data = {}, headers = {}, options = {}) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/hiera/backend/eyaml/encryptors/vault_rs/httphandler.rb', line 15 def post(uri_str, data={}, headers={}, ={}) uri = URI.parse(uri_str) request = Net::HTTP::Post.new(uri.path) request.body = data.to_json http_send(uri, request, headers, ) end |
.put(uri_str, data = {}, headers = {}, options = {}) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/hiera/backend/eyaml/encryptors/vault_rs/httphandler.rb', line 22 def put(uri_str, data={}, headers={}, ={}) uri = URI.parse(uri_str) request = Net::HTTP::Put.new(uri.path) request.body = data.to_json http_send(uri, request, headers, ) end |