Method: Lisk::Client#query_put
- Defined in:
- lib/lisk/client.rb
#query_put(endpoint, params) ⇒ Object
Handles PUT requests to the given Lisk Core API endpoint
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/lisk/client.rb', line 108 def query_put endpoint, params if not @ssl # fixme "#{self}::#{__method__} Allow HTTPS requests" begin node = ::Net::HTTP.new @host, @port header = {'Content-Type': 'application/json'} uri = URI.parse "http://#{host}:#{port}/api/#{endpoint}" uri.query = URI.encode_www_form params request = ::Net::HTTP::Put.new uri, header request.body = params.to_json response = node.request request @active = true result = JSON::parse response.body rescue Timeout::Error => e @active = false p "Can't connect to the Lisk node: Timeout!" rescue Errno::EHOSTUNREACH => e @active = false p "Can't connect to the Lisk node: Host Unreachable!" rescue Errno::ECONNREFUSED => e @active = false p "Can't connect to the Lisk node: Connection Refused!" end end end |