Module: Hyperkit::Connection
- Included in:
- Client
- Defined in:
- lib/hyperkit/connection.rb
Overview
Network layer for API clients.
Constant Summary collapse
- CONVENIENCE_HEADERS =
Set.new([:accept, :content_type])
Instance Method Summary collapse
-
#agent ⇒ Sawyer::Agent
Hypermedia agent for the GitHub API.
-
#delete(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP DELETE request.
-
#get(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP GET request.
-
#head(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP HEAD request.
-
#last_response ⇒ Sawyer::Response
Response for last HTTP request.
-
#patch(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP PATCH request.
-
#post(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP POST request.
-
#put(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP PUT request.
-
#root ⇒ Sawyer::Resource
Fetch the root resource for the API.
Instance Method Details
#agent ⇒ Sawyer::Agent
Hypermedia agent for the GitHub API
89 90 91 92 93 94 95 |
# File 'lib/hyperkit/connection.rb', line 89 def agent @agent ||= Sawyer::Agent.new(endpoint, ) do |http| http.headers[:accept] = default_media_type http.headers[:content_type] = "application/json" http.headers[:user_agent] = user_agent end end |
#delete(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP DELETE request
73 74 75 |
# File 'lib/hyperkit/connection.rb', line 73 def delete(url, = {}) request :delete, url, end |
#get(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP GET request
37 38 39 |
# File 'lib/hyperkit/connection.rb', line 37 def get(url, = {}) request :get, url, parse_query_and_convenience_headers() end |
#head(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP HEAD request
82 83 84 |
# File 'lib/hyperkit/connection.rb', line 82 def head(url, = {}) request :head, url, parse_query_and_convenience_headers() end |
#last_response ⇒ Sawyer::Response
Response for last HTTP request
107 108 109 |
# File 'lib/hyperkit/connection.rb', line 107 def last_response @last_response if defined? @last_response end |
#patch(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP PATCH request
64 65 66 |
# File 'lib/hyperkit/connection.rb', line 64 def patch(url, = {}) request :patch, url, end |
#post(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP POST request
46 47 48 |
# File 'lib/hyperkit/connection.rb', line 46 def post(url, = {}) request :post, url, end |
#put(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP PUT request
55 56 57 |
# File 'lib/hyperkit/connection.rb', line 55 def put(url, = {}) request :put, url, end |
#root ⇒ Sawyer::Resource
Fetch the root resource for the API
100 101 102 |
# File 'lib/hyperkit/connection.rb', line 100 def root get "/" end |