Class: RSolr::HTTPClient::Adapter::NetHTTP
- Inherits:
-
Object
- Object
- RSolr::HTTPClient::Adapter::NetHTTP
- Includes:
- Util
- Defined in:
- lib/rsolr/http_client/adapter/net_http.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #get(path, params = {}) ⇒ Object
-
#initialize(opts = {}) ⇒ NetHTTP
constructor
A new instance of NetHTTP.
- #post(path, data, params = {}, headers = {}) ⇒ Object
Methods included from Util
#build_param, #build_url, #escape, #hash_to_query
Constructor Details
#initialize(opts = {}) ⇒ NetHTTP
Returns a new instance of NetHTTP.
10 11 12 13 |
# File 'lib/rsolr/http_client/adapter/net_http.rb', line 10 def initialize(opts={}) @uri = URI.parse(opts[:url]) @connection = Net::HTTP.new(@uri.host, @uri.port) end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
8 9 10 |
# File 'lib/rsolr/http_client/adapter/net_http.rb', line 8 def connection @connection end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
7 8 9 |
# File 'lib/rsolr/http_client/adapter/net_http.rb', line 7 def uri @uri end |
Instance Method Details
#get(path, params = {}) ⇒ Object
15 16 17 18 19 |
# File 'lib/rsolr/http_client/adapter/net_http.rb', line 15 def get(path, params={}) url = _build_url(path, params) net_http_response = @connection.get(url) create_http_context(net_http_response, url, path, params) end |
#post(path, data, params = {}, headers = {}) ⇒ Object
21 22 23 24 25 |
# File 'lib/rsolr/http_client/adapter/net_http.rb', line 21 def post(path, data, params={}, headers={}) url = _build_url(path, params) net_http_response = @connection.post(url, data, headers) create_http_context(net_http_response, url, path, params, data, headers) end |