Module: LoginWithGithub::ApiBase

Included in:
Api
Defined in:
lib/login_with_github/api_base.rb

Overview

make http requests

Instance Method Summary collapse

Instance Method Details

#http_delete(options) ⇒ Object



23
24
25
26
27
# File 'lib/login_with_github/api_base.rb', line 23

def http_delete(options)
  request = Net::HTTP::Delete.new(options[:uri], options[:head])
  request.body = options[:body] if options[:body]
  request_http(options, request)
end

#http_get(options) ⇒ Object



7
8
9
10
11
# File 'lib/login_with_github/api_base.rb', line 7

def http_get(options)
  request = Net::HTTP::Get.new(options[:uri], options[:head])
  request.body = options[:body] if options[:body]
  request_http(options, request).body
end

#http_post(options) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/login_with_github/api_base.rb', line 13

def http_post(options)
  request = Net::HTTP::Post.new(options[:uri], options[:head])
  request.body = options[:body] if options[:body]
  request.basic_auth(*options[:auth]) if options[:auth]

  return request_http(options, request).body if options[:body_response]

  request_http(options, request).body
end