Skip to content

Instantly share code, notes, and snippets.

@AlexWheeler
Created January 21, 2017 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexWheeler/aeac1a082574fa5590d1173b7b36e8ff to your computer and use it in GitHub Desktop.
Save AlexWheeler/aeac1a082574fa5590d1173b7b36e8ff to your computer and use it in GitHub Desktop.
module Request
HEADERS = { 'Content-Type' => 'application/json' }.freeze
def self.add_headers(headers)
HEADERS.merge!(headers)
end
def get_request(path)
uri = URI.parse(path)
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Get.new(uri.request_uri, HEADERS)
response = http.request(request)
end
end
class Client
include Request
def initialize()
Request.add_headers("X-Custom" => "foo")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment