Module: HTTPWrapper

Included in:
Nsqd, Nsqlookupd
Defined in:
lib/nsq-cluster/http_wrapper.rb

Instance Method Summary collapse

Instance Method Details

#get(path, params = {}) ⇒ Object



18
19
20
21
22
# File 'lib/nsq-cluster/http_wrapper.rb', line 18

def get(path, params = {})
  uri = uri(path)
  uri.query = URI.encode_www_form(params)
  Net::HTTP.get_response(uri)
end

#post(path, params = {}, body = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/nsq-cluster/http_wrapper.rb', line 7

def post(path, params = {}, body = nil)
  uri = uri("#{path}?#{URI.encode_www_form(params)}")
  request = Net::HTTP::Post.new(uri)
  request.body = body

  Net::HTTP.start(uri.hostname, uri.port) do |http|
    http.request(request)
  end
end