Class: CurseClient::HTTP

Inherits:
Object
  • Object
show all
Defined in:
lib/curse_client/http.rb

Class Method Summary collapse

Class Method Details

.get(uri, options = {}, &block) ⇒ Object



6
7
8
9
10
11
# File 'lib/curse_client/http.rb', line 6

def self.get(uri, options = {}, &block)
  uri = create_uri(uri)
  request = Net::HTTP::Get.new(uri.request_uri)
  request.initialize_http_header(options[:headers]) if options[:headers]
  send_request(uri, request, &block)
end

.post(uri, body, options = {}, &block) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/curse_client/http.rb', line 13

def self.post(uri, body, options = {}, &block)
  uri = create_uri(uri)
  request = Net::HTTP::Post.new(uri.request_uri)
  request.initialize_http_header(options[:headers]) if options[:headers]
  request.body = parse_request_body(body, options[:format] || :json)
  send_request(uri, request, &block)
end