Class: CeleryClient::HTTP
- Inherits:
-
Object
- Object
- CeleryClient::HTTP
- Defined in:
- lib/celery_client/http.rb
Instance Method Summary collapse
- #get(path, params = {}) ⇒ Object
-
#initialize(config) ⇒ HTTP
constructor
A new instance of HTTP.
- #post(path, params = {}) ⇒ Object
Constructor Details
#initialize(config) ⇒ HTTP
Returns a new instance of HTTP.
7 8 9 10 11 |
# File 'lib/celery_client/http.rb', line 7 def initialize(config) @url = config.fetch('url') @username = config.fetch('username') @password = config.fetch('password') end |
Instance Method Details
#get(path, params = {}) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/celery_client/http.rb', line 13 def get(path, params={}) uri = URI("#{@url}#{path}") uri.query = URI.encode_www_form(params) request = Net::HTTP::Get.new(uri.request_uri) make_request(request, uri) end |
#post(path, params = {}) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/celery_client/http.rb', line 20 def post(path, params={}) uri = URI("#{@url}#{path}") request = Net::HTTP::Post.new(uri.request_uri) request.set_form_data(params) make_request(request, uri) end |