module HTTPWrapper

Public Instance Methods

get(path, params = {}) click to toggle source
# 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) click to toggle source
# 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

Private Instance Methods

uri(path) click to toggle source
# File lib/nsq-cluster/http_wrapper.rb, line 28
def uri(path)
  URI("http://#{@host}:#{@http_port}/#{path}")
end