Class: Sekken::HTTPClient
- Inherits:
-
Object
- Object
- Sekken::HTTPClient
- Defined in:
- lib/sekken/httpclient.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Public: Returns the HTTPClient instance to configure.
Instance Method Summary collapse
-
#get(url) ⇒ Object
Public: Executes an HTTP GET request to a given url.
-
#initialize ⇒ HTTPClient
constructor
A new instance of HTTPClient.
-
#post(url, headers, body) ⇒ Object
Public: Executes an HTTP POST request to a given url with headers and body.
Constructor Details
#initialize ⇒ HTTPClient
Returns a new instance of HTTPClient.
6 7 8 |
# File 'lib/sekken/httpclient.rb', line 6 def initialize @client = ::HTTPClient.new end |
Instance Attribute Details
#client ⇒ Object (readonly)
Public: Returns the HTTPClient instance to configure.
11 12 13 |
# File 'lib/sekken/httpclient.rb', line 11 def client @client end |
Instance Method Details
#get(url) ⇒ Object
Public: Executes an HTTP GET request to a given url.
Returns the raw HTTP response body as a String.
16 17 18 |
# File 'lib/sekken/httpclient.rb', line 16 def get(url) request(:get, url, {}, nil) end |
#post(url, headers, body) ⇒ Object
Public: Executes an HTTP POST request to a given url with headers and body.
Returns the raw HTTP response body as a String.
23 24 25 |
# File 'lib/sekken/httpclient.rb', line 23 def post(url, headers, body) request(:post, url, headers, body) end |