Sha256: 833a40baabd98bdd71f2777ad763699fc94ffeb1b00ceb69c58363c180da5dcb

Contents?: true

Size: 573 Bytes

Versions: 2

Compression:

Stored size: 573 Bytes

Contents

module PackageTracker
  class Request
    def self.get(uri, path, body, options={})
      do_request(Net::HTTP::Get, uri, path, body, options)
    end

    def self.post(uri, path, body, options={})
      do_request(Net::HTTP::Post, uri, path, body, options)
    end
    
    def self.do_request(http_method, uri, path, body, options={})      
      raw_request = http_method.new(path)
      raw_request.body = body
      
      http = Net::HTTP.new(uri, options[:port])
      http.use_ssl = true if options[:https]
      
      http.request(raw_request)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
package_tracker-0.0.3 lib/package_tracker/request.rb
package_tracker-0.0.2 lib/package_tracker/request.rb